summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-09-24 21:45:37 +0200
committerSebastian Geerken <devnull@localhost>2014-09-24 21:45:37 +0200
commitbcebc40e56a88fac5fbdd4cc04d74d53ac6ec3ff (patch)
tree004667ce96691a83841c2fb644328037efa38e9f
parentfd1293cb0debeb0fbda3993e14eb43a2ff2bfd15 (diff)
Avoid dublicate drawing.
-rw-r--r--doc/dw-stacking-context.doc30
-rw-r--r--dw/ooffloatsmgr.cc7
-rw-r--r--dw/oofpositionedmgr.cc3
-rw-r--r--dw/stackingcontextmgr.cc2
-rw-r--r--dw/stackingcontextmgr.hh8
-rw-r--r--dw/table.cc3
-rw-r--r--dw/textblock.cc5
7 files changed, 37 insertions, 21 deletions
diff --git a/doc/dw-stacking-context.doc b/doc/dw-stacking-context.doc
index 59d22f1c..47854546 100644
--- a/doc/dw-stacking-context.doc
+++ b/doc/dw-stacking-context.doc
@@ -31,12 +31,12 @@ The first is done from bottom to top, the latter from top to bottom.
I'm here referring to the simplified description in
<a href="http://www.w3.org/TR/CSS2/visuren.html#z-index">section
9.9.1</a>. The table shows a recommended order for the implementations
-of dw::core::Widget::draw and dw::core::Widget::getWidgetAtPoint (for
-the latter, read from bottom to top):
+of dw::core::Widget::draw and dw::core::Widget::getWidgetAtPoint
+(for the latter, read from bottom to top)<sup>1</sup>:
<table>
<tr>
-<th> CSS specification <th> Drawing <th> Mouse events
+<th> CSS specification <th> Drawing <th> Mouse events<sup>2</sup>
<tr>
<td> *1. the background and borders of the element forming the
stacking context.*
@@ -61,8 +61,8 @@ the latter, read from bottom to top):
This order differs from the specified order, but
since floats and in-flow elements do not overlap,
- this difference has no effect.
-<td rowspan="4"> ...
+ this difference has no effect.<sup>3</sup>
+<td rowspan="4"> ...<sup>3</sup>
<tr>
<td> *4. the non-positioned floats.*
<tr>
@@ -87,15 +87,19 @@ the latter, read from bottom to top):
Notes:
-- Handling mouse events is, at this time, not implemented at all.
+<sup>1</sup>) This is not quite in conformance with the specification:
+ this description refers to any widget, not only widgets
+ establishing a stacking context. Does this make a
+ difference?
-- This is not quite in conformance with the specification: this
- description refers to any widget, not only widgets establishing a
- stacking context. Does this make a difference?
+<sup>2</sup>) Handling mouse events is, at this time, not implemented
+ at all.
-- Drawing (and handling mouse events, respectively) should avoid
- dublicate calls: Widgets drawn by dw::core::StackingContextMgr::drawBottom
- and by dw::core::StackingContextMgr::drawTop should be excluded
- elsewhere.
+<sup>3</sup>) Drawing (and handling mouse events, respectively) should
+ avoid dublicate calls: Widgets drawn by
+ dw::core::StackingContextMgr::drawBottom and by
+ dw::core::StackingContextMgr::drawTop should be excluded
+ elsewhere. This can be tested with
+ dw::core::StackingContextMgr::handledByStackingContextMgr.
*/ \ No newline at end of file
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 7850b18f..eecd4faa 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -1284,10 +1284,11 @@ void OOFFloatsMgr::drawFloats (SortedFloatsVector *list, View *view,
// first float fitting into the area, and iterate until one is
// found below the area.
for (int i = 0; i < list->size(); i++) {
- Float *vloat = list->get(i);
+ Widget *childWidget = list->get(i)->getWidget ();
Rectangle childArea;
- if (vloat->getWidget()->intersects (area, &childArea))
- vloat->getWidget()->draw (view, &childArea);
+ if (!StackingContextMgr::handledByStackingContextMgr (childWidget) &&
+ childWidget->intersects (area, &childArea))
+ childWidget->draw (view, &childArea);
}
}
diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc
index 3efb5002..4799ec8c 100644
--- a/dw/oofpositionedmgr.cc
+++ b/dw/oofpositionedmgr.cc
@@ -176,7 +176,8 @@ void OOFPositionedMgr::draw (View *view, Rectangle *area)
for (int i = 0; i < children->size(); i++) {
Widget *childWidget = children->get(i)->widget;
Rectangle childArea;
- if (childWidget->intersects (area, &childArea))
+ if (!StackingContextMgr::handledByStackingContextMgr (childWidget) &&
+ childWidget->intersects (area, &childArea))
childWidget->draw (view, &childArea);
}
diff --git a/dw/stackingcontextmgr.cc b/dw/stackingcontextmgr.cc
index 333f0707..b3573a3f 100644
--- a/dw/stackingcontextmgr.cc
+++ b/dw/stackingcontextmgr.cc
@@ -67,7 +67,7 @@ void StackingContextMgr::drawBottom (View *view, Rectangle *area)
void StackingContextMgr::drawTop (View *view, Rectangle *area)
{
- DBG_OBJ_ENTER ("draw", 0, "drawBottom", "%d, %d, %d * %d",
+ DBG_OBJ_ENTER ("draw", 0, "drawTop", "%d, %d, %d * %d",
area->x, area->y, area->width, area->height);
draw (view, area, 0, INT_MAX);
DBG_OBJ_LEAVE ();
diff --git a/dw/stackingcontextmgr.hh b/dw/stackingcontextmgr.hh
index 36acfb11..cbb59231 100644
--- a/dw/stackingcontextmgr.hh
+++ b/dw/stackingcontextmgr.hh
@@ -35,6 +35,14 @@ public:
widget->getStyle()->zIndex != style::Z_INDEX_AUTO;
}
+ inline static bool handledByStackingContextMgr (Widget *widget) {
+ // Each widget establishing a stacking context is child of another
+ // stacking context, so drawn by StackingContextMgr::drawTop or
+ // StackingContextMgr::drawBottom etc.
+ return widget->getParent () != NULL
+ && isEstablishingStackingContext (widget);
+ }
+
void addChildSCWidget (Widget *widget);
void drawBottom (View *view, Rectangle *area);
diff --git a/dw/table.cc b/dw/table.cc
index d443327b..4259111a 100644
--- a/dw/table.cc
+++ b/dw/table.cc
@@ -382,7 +382,8 @@ void Table::draw (core::View *view, core::Rectangle *area)
if (childDefined (i)) {
Widget *child = children->get(i)->cell.widget;
core::Rectangle childArea;
- if (child->intersects (area, &childArea))
+ if (!core::StackingContextMgr::handledByStackingContextMgr (child) &&
+ child->intersects (area, &childArea))
child->draw (view, &childArea);
}
}
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 9bff14d7..df38a8e7 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -1447,8 +1447,9 @@ void Textblock::drawLine (Line *line, core::View *view, core::Rectangle *area)
if (word->content.type == core::Content::WIDGET_IN_FLOW) {
core::Widget *child = word->content.widget;
core::Rectangle childArea;
-
- if (child->intersects (area, &childArea))
+ if (!core::StackingContextMgr::handledByStackingContextMgr
+ (child) &&
+ child->intersects (area, &childArea))
child->draw (view, &childArea);
} else {
int wordIndex2 = wordIndex;