1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
|
/*
* Dillo Widget
*
* Copyright 2014 Sebastian Geerken <sgeerken@dillo.org>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "oofawarewidget.hh"
#include "ooffloatsmgr.hh"
#include "oofposabsmgr.hh"
#include "oofposfixedmgr.hh"
using namespace dw;
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 {
const char *OOFAwareWidget::OOFM_NAME[NUM_OOFM] = {
"FLOATS", "ABSOLUTE", "FIXED"
};
OOFAwareWidget::OOFStackingIterator::OOFStackingIterator
(OOFAwareWidget *widget, bool atEnd)
{
if (atEnd) {
majorLevel = OOFStackingIterator::END - 1;
minorLevel = widget->getLastMinorLevel (majorLevel);
index = widget->getLastLevelIndex (majorLevel, minorLevel);
} else {
majorLevel = OOFStackingIterator::START + 1;
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) {
case START: return "START";
case BACKGROUND: return "BACKGROUND";
case SC_BOTTOM: return "SC_BOTTOM";
case IN_FLOW: return "IN_FLOW";
case OOF_REF: return "OOF_REF";
case OOF_CONT: return "OOF_CONT";
case SC_TOP: return "SC_TOP";
case END: return "END";
default: return "???";
}
}
void OOFAwareWidget::OOFStackingIterator::intoStringBuffer(StringBuffer *sb)
{
sb->append ("(");
sb->append (majorLevelText (majorLevel));
sb->append (", ");
sb->appendInt (minorLevel);
sb->append (", ");
sb->appendInt (index);
sb->append (")");
}
int OOFAwareWidget::CLASS_ID = -1;
OOFAwareWidget::OOFAwareWidget ()
{
DBG_OBJ_CREATE ("dw::oof::OOFAwareWidget");
registerName ("dw::oof::OOFAwareWidget", &CLASS_ID);
for (int i = 0; i < NUM_OOFM; i++) {
oofContainer[i] = NULL;
DBG_OBJ_ARRSET_PTR ("oofContainer", i, oofContainer[i]);
outOfFlowMgr[i] = NULL;
}
}
OOFAwareWidget::~OOFAwareWidget ()
{
for (int i = 0; i < NUM_OOFM; i++) {
if(outOfFlowMgr[i]) {
// I feel more comfortable by letting the OOF aware widget delete
// these widgets, instead of doing this in ~OutOfFlowMgr.
for (int j = 0; j < outOfFlowMgr[i]->getNumWidgets (); j++)
delete outOfFlowMgr[i]->getWidget (j);
delete outOfFlowMgr[i];
}
}
DBG_OBJ_DELETE ();
}
void OOFAwareWidget::notifySetAsTopLevel ()
{
for (int i = 0; i < NUM_OOFM; i++) {
oofContainer[i] = this;
DBG_OBJ_ARRSET_PTR ("oofContainer", i, oofContainer[i]);
}
}
bool OOFAwareWidget::getOOFMIndex (Widget *widget)
{
if (testWidgetFloat (widget))
return OOFM_FLOATS;
else if (testWidgetAbsolutelyPositioned (widget))
return OOFM_ABSOLUTE;
else if (testWidgetFixedlyPositioned (widget))
return OOFM_FIXED;
else {
lout::misc::assertNotReached ();
return -1;
}
}
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 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 == DISPLAY_INLINE_BLOCK ||
// Same for blocks with 'overview' set to another value than
// (the default value) 'visible'.
widget->getStyle()->overflow != OVERFLOW_VISIBLE ||
// Finally, "out of flow" in a narrower sense: floats;
// absolutely and fixedly positioned elements. (No
// relatively positioned elements; since the latters
// constitute a stacking context, drawing of floats gets
// somewhat more complicated; see "interrupting the drawing
// process" in "dw-stacking-context.doc".
testWidgetOutOfFlow (widget)));
case OOFM_ABSOLUTE:
// We use the toplevel widget as container, i. e. parent widget.
// See also OOFPosAbsMgr::isReference for the definition of the
// "reference widget".
//return widget->getParent() == NULL;
// The above does not work. Temporary re-enact old behaviour:
return widget->instanceOf (OOFAwareWidget::CLASS_ID) &&
(widget->getParent() == NULL ||
OOFAwareWidget::testWidgetPositioned (widget));
case OOFM_FIXED:
// The single container for fixedly positioned elements is the
// toplevel (canvas; actually the viewport). (The toplevel
// widget should always be a textblock; at least this is the
// case in dillo.)
return widget->getParent() == NULL;
default:
// compiler happiness
lout::misc::assertNotReached ();
return false;
}
}
void OOFAwareWidget::notifySetParent ()
{
// Search for containing blocks.
for (int oofmIndex = 0; oofmIndex < NUM_OOFM; oofmIndex++) {
oofContainer[oofmIndex] = NULL;
for (Widget *widget = this;
widget != NULL && oofContainer[oofmIndex] == NULL;
widget = widget->getParent ())
if (isOOFContainer (widget, oofmIndex)) {
assert (widget->instanceOf (OOFAwareWidget::CLASS_ID));
oofContainer[oofmIndex] = (OOFAwareWidget*)widget;
}
DBG_OBJ_ARRSET_PTR ("oofContainer", oofmIndex, oofContainer[oofmIndex]);
assert (oofContainer[oofmIndex] != NULL);
}
}
void OOFAwareWidget::initOutOfFlowMgrs ()
{
if (oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS] == NULL) {
oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS] =
new OOFFloatsMgr (oofContainer[OOFM_FLOATS]);
DBG_OBJ_ASSOC (oofContainer[OOFM_FLOATS],
oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS]);
}
if (oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE] == NULL) {
oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE] =
new OOFPosAbsMgr (oofContainer[OOFM_ABSOLUTE]);
DBG_OBJ_ASSOC (oofContainer[OOFM_ABSOLUTE],
oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE]);
}
if (oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED] == NULL) {
oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED] =
new OOFPosFixedMgr (oofContainer[OOFM_FIXED]);
DBG_OBJ_ASSOC (oofContainer[OOFM_FIXED],
oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED]);
}
}
void OOFAwareWidget::correctRequisitionByOOF (Requisition *requisition,
void (*splitHeightFun) (int, int*,
int*))
{
DBG_OBJ_ENTER ("resize", 0, "correctRequisitionByOOF", "%d * (%d + %d), ...",
requisition->width, requisition->ascent,
requisition->descent);
for (int i = 0; i < NUM_OOFM; i++) {
if (outOfFlowMgr[i]) {
DBG_OBJ_MSGF ("resize", 1, "OOFM for %s", OOFM_NAME[i]);
DBG_OBJ_MSG_START ();
int oofWidth, oofHeight;
outOfFlowMgr[i]->getSize (requisition, &oofWidth, &oofHeight);
DBG_OBJ_MSGF ("resize", 1, "result: %d * %d", oofWidth, oofHeight);
if (oofWidth > requisition->width) {
if (outOfFlowMgr[i]->containerMustAdjustExtraSpace () &&
adjustExtraSpaceWhenCorrectingRequisitionByOOF ()) {
extraSpace.right = max (extraSpace.right,
oofWidth - requisition->width);
DBG_OBJ_SET_NUM ("extraSpace.right", extraSpace.right);
}
requisition->width = oofWidth;
}
if (oofHeight > requisition->ascent + requisition->descent) {
if (outOfFlowMgr[i]->containerMustAdjustExtraSpace () &&
adjustExtraSpaceWhenCorrectingRequisitionByOOF ()) {
extraSpace.bottom = max (extraSpace.bottom,
oofHeight - (requisition->ascent +
requisition->descent));
DBG_OBJ_SET_NUM ("extraSpace.bottom", extraSpace.bottom);
}
splitHeightFun (oofHeight,
&requisition->ascent, &requisition->descent);
}
DBG_OBJ_MSGF ("resize", 1, "after correction: %d * (%d + %d)",
requisition->width, requisition->ascent,
requisition->descent);
DBG_OBJ_MSG_END ();
} else
DBG_OBJ_MSGF ("resize", 1, "no OOFM for %s", OOFM_NAME[i]);
}
DBG_OBJ_LEAVE ();
}
void OOFAwareWidget::correctExtremesByOOF (Extremes *extremes)
{
DBG_OBJ_ENTER ("resize", 0, "correctExtremesByOOF", "%d (%d) / %d (%d)",
extremes->minWidth, extremes->minWidthIntrinsic,
extremes->maxWidth, extremes->maxWidthIntrinsic);
for (int i = 0; i < NUM_OOFM; i++) {
if (outOfFlowMgr[i]) {
DBG_OBJ_MSGF ("resize", 1, "OOFM for %s", OOFM_NAME[i]);
DBG_OBJ_MSG_START ();
int oofMinWidth, oofMaxWidth;
outOfFlowMgr[i]->getExtremes (extremes, &oofMinWidth, &oofMaxWidth);
DBG_OBJ_MSGF ("resize", 1, "result: %d / %d",
oofMinWidth, oofMaxWidth);
extremes->minWidth = max (extremes->minWidth, oofMinWidth);
extremes->minWidthIntrinsic = max (extremes->minWidthIntrinsic,
oofMinWidth);
extremes->maxWidth = max (extremes->maxWidth, oofMaxWidth);
extremes->maxWidthIntrinsic = max (extremes->maxWidthIntrinsic,
oofMinWidth);
extremes->adjustmentWidth = max (extremes->adjustmentWidth,
oofMinWidth);
DBG_OBJ_MSGF ("resize", 1, "after correction: %d (%d) / %d (%d)",
extremes->minWidth, extremes->minWidthIntrinsic,
extremes->maxWidth, extremes->maxWidthIntrinsic);
DBG_OBJ_MSG_END ();
} else
DBG_OBJ_MSGF ("resize", 1, "no OOFM for %s", OOFM_NAME[i]);
}
DBG_OBJ_LEAVE ();
}
void OOFAwareWidget::sizeAllocateStart (Allocation *allocation)
{
for (int i = 0; i < NUM_OOFM; i++)
if (oofContainer[i]->outOfFlowMgr[i])
oofContainer[i]->outOfFlowMgr[i]->sizeAllocateStart (this, allocation);
}
void OOFAwareWidget::sizeAllocateEnd ()
{
for (int i = 0; i < NUM_OOFM; i++)
if (oofContainer[i]->outOfFlowMgr[i])
oofContainer[i]->outOfFlowMgr[i]->sizeAllocateEnd (this);
}
void OOFAwareWidget::containerSizeChangedForChildrenOOF ()
{
for (int i = 0; i < NUM_OOFM; i++)
if (outOfFlowMgr[i])
outOfFlowMgr[i]->containerSizeChangedForChildren ();
}
bool OOFAwareWidget::doesWidgetOOFInterruptDrawing (Widget *widget)
{
DBG_OBJ_ENTER ("draw", 0, "doesWidgetOOFInterruptDrawing", "%p", widget);
// This is the generator of the widget.
int oofmIndex = getOOFMIndex (widget);
DBG_OBJ_MSGF ("draw", 1, "oofmIndex = %d", oofmIndex);
int cl = oofContainer[oofmIndex]->stackingContextWidget->getLevel (),
gl = stackingContextWidget->getLevel ();
DBG_OBJ_MSGF ("draw", 1,"%d < %d => %s", cl, gl, cl < gl ? "true" : "false");
DBG_OBJ_LEAVE ();
return cl < gl;
}
void OOFAwareWidget::draw (View *view, Rectangle *area, DrawingContext *context)
{
DBG_OBJ_ENTER ("draw", 0, "draw", "%d, %d, %d * %d",
area->x, area->y, area->width, area->height);
for (int level = 0; level < OOFStackingIterator::END; level++)
drawLevel (view, area, level, context);
DBG_OBJ_LEAVE ();
}
void OOFAwareWidget::drawLevel (View *view, Rectangle *area, int level,
DrawingContext *context)
{
DBG_OBJ_ENTER ("draw", 0, "OOFAwareWidget::drawLevel",
"(%d, %d, %d * %d), %s",
area->x, area->y, area->width, area->height,
OOFStackingIterator::majorLevelText (level));
switch (level) {
case OOFStackingIterator::START:
break;
case OOFStackingIterator::BACKGROUND:
drawWidgetBox (view, area, false);
break;
case OOFStackingIterator::SC_BOTTOM:
if (stackingContextMgr)
stackingContextMgr->drawBottom (view, area, context);
break;
case OOFStackingIterator::IN_FLOW:
// Should be implemented in the sub class.
break;
case OOFStackingIterator::OOF_REF:
// Should be implemented in the sub class (when references are hold).
break;
case OOFStackingIterator::OOF_CONT:
drawOOF (view, area, context);
break;
case OOFStackingIterator::SC_TOP:
if (stackingContextMgr)
stackingContextMgr->drawTop (view, area, context);
break;
case OOFStackingIterator::END:
break;
}
DBG_OBJ_LEAVE ();
}
void OOFAwareWidget::drawOOF (View *view, Rectangle *area,
DrawingContext *context)
{
for (int i = 0; i < NUM_OOFM; i++) {
if(outOfFlowMgr[i])
outOfFlowMgr[i]->draw (view, area, context);
}
}
Widget *OOFAwareWidget::getWidgetAtPoint (int x, int y,
StackingIteratorStack *iteratorStack,
Widget **interruptedWidget)
{
DBG_OBJ_ENTER ("events", 0, "getWidgetAtPoint", "%d, %d", x, y);
Widget *widgetAtPoint = NULL;
if (wasAllocated () && x >= allocation.x && y >= allocation.y &&
x <= allocation.x + allocation.width &&
y <= allocation.y + getHeight ()) {
while (widgetAtPoint == NULL && *interruptedWidget == NULL &&
((OOFStackingIterator*)iteratorStack->getTop())->majorLevel
> OOFStackingIterator::START) {
widgetAtPoint =
getWidgetAtPointLevel (x, y, iteratorStack, interruptedWidget,
((OOFStackingIterator*)iteratorStack
->getTop())->majorLevel);
if (*interruptedWidget) {
assert (widgetAtPoint == NULL); // Not both set.
if ((*interruptedWidget)->getParent () == this) {
DBG_OBJ_MSGF ("events", 1,
"interrupted at %p, searching widget seperately",
*interruptedWidget);
DBG_IF_RTFL {
StringBuffer sb;
iteratorStack->intoStringBuffer (&sb);
DBG_OBJ_MSGF ("events", 2, "iteratorStack: %s",
sb.getChars ());
}
// Similar to Widget::getWidgetAtPointToplevel. Nested
// interruptions are not allowed.
StackingIteratorStack iteratorStack2;
Widget *interruptedWidget2 = NULL;
widgetAtPoint = (*interruptedWidget)
->getWidgetAtPointTotal (x, y, &iteratorStack2,
&interruptedWidget2);
assert (interruptedWidget2 == NULL);
((OOFStackingIterator*)iteratorStack->getTop())
->registerWidgetDrawnAfterInterruption (*interruptedWidget);
// Continue with the current state of "iterator".
*interruptedWidget = NULL;
DBG_OBJ_MSG ("events", 1, "done with interruption");
// The interrupted widget may have returned non-NULL. In this
// case, the stack must be cleaned up explicitly, which would
// otherwise be done implicitly during the further search.
// (Since drawing is never quit completely, this problem only
// applies to searching.)
if (widgetAtPoint) {
iteratorStack->cleanup ();
DBG_IF_RTFL {
StringBuffer sb;
iteratorStack->intoStringBuffer (&sb);
DBG_OBJ_MSGF ("events", 2,
"iteratorStack after cleanup: %s",
sb.getChars ());
}
}
}
} else {
OOFStackingIterator* osi =
(OOFStackingIterator*)iteratorStack->getTop();
osi->majorLevel--;
if (osi->majorLevel > OOFStackingIterator::START) {
osi->minorLevel = getLastMinorLevel (osi->majorLevel);
osi->index =
getLastLevelIndex (osi->majorLevel, osi->minorLevel);
}
}
}
}
DBG_OBJ_MSGF ("events", 1, "=> %p (i: %p)",
widgetAtPoint, *interruptedWidget);
DBG_OBJ_LEAVE ();
return widgetAtPoint;
}
Widget *OOFAwareWidget::getWidgetAtPointLevel (int x, int y,
StackingIteratorStack
*iteratorStack,
Widget **interruptedWidget,
int majorLevel)
{
DBG_OBJ_ENTER ("events", 0, "OOFAwareWidget::getWidgetAtPointLevel",
"%d, %d, %s", x, y,
OOFStackingIterator::majorLevelText (majorLevel));
Widget *widgetAtPoint = NULL;
switch (majorLevel) {
case OOFStackingIterator::BACKGROUND:
if (wasAllocated () && x >= allocation.x && y >= allocation.y &&
x <= allocation.x + allocation.width &&
y <= allocation.y + getHeight ())
widgetAtPoint = this;
break;
case OOFStackingIterator::SC_BOTTOM:
if (stackingContextMgr) {
OOFStackingIterator *osi =
(OOFStackingIterator*)iteratorStack->getTop ();
widgetAtPoint =
stackingContextMgr->getBottomWidgetAtPoint (x, y, iteratorStack,
interruptedWidget,
&osi->minorLevel,
&osi->index);
}
break;
case OOFStackingIterator::IN_FLOW:
// Should be implemented in the sub class.
assertNotReached ();
break;
case OOFStackingIterator::OOF_REF:
// Should be implemented in the sub class (when references are hold).
break;
case OOFStackingIterator::OOF_CONT:
widgetAtPoint =
getWidgetOOFAtPoint (x, y, iteratorStack, interruptedWidget);
break;
case OOFStackingIterator::SC_TOP:
if (stackingContextMgr) {
OOFStackingIterator *osi =
(OOFStackingIterator*)iteratorStack->getTop ();
widgetAtPoint =
stackingContextMgr->getTopWidgetAtPoint (x, y, iteratorStack,
interruptedWidget,
&osi->minorLevel,
&osi->index);
}
break;
default:
assertNotReached ();
}
DBG_OBJ_MSGF ("events", 1, "=> %p (i: %p)",
widgetAtPoint, *interruptedWidget);
DBG_OBJ_LEAVE ();
return widgetAtPoint;
}
Widget *OOFAwareWidget::getWidgetOOFAtPoint (int x, int y,
core::StackingIteratorStack
*iteratorStack,
Widget **interruptedWidget)
{
OOFStackingIterator *osi = (OOFStackingIterator*)iteratorStack->getTop ();
assert (osi->majorLevel == OOFStackingIterator::OOF_CONT);
Widget *widgetAtPoint = NULL;
while (*interruptedWidget == NULL && widgetAtPoint == NULL &&
osi->minorLevel >= 0) {
if (outOfFlowMgr[osi->minorLevel])
widgetAtPoint =
outOfFlowMgr[osi->minorLevel]->getWidgetAtPoint (x, y,
iteratorStack,
interruptedWidget,
&(osi->index));
if (*interruptedWidget == NULL) {
osi->minorLevel--;
if (osi->minorLevel > 0 && outOfFlowMgr[osi->minorLevel] != NULL)
osi->index = outOfFlowMgr[osi->minorLevel]->getNumWidgets () - 1;
}
}
return widgetAtPoint;
}
int OOFAwareWidget::getLastMinorLevel (int majorLevel)
{
switch (majorLevel) {
case OOFStackingIterator::BACKGROUND:
return 0;
case OOFStackingIterator::SC_BOTTOM:
case OOFStackingIterator::SC_TOP:
// See StackingContextMgr: refers to list of z-indices; region
// (top or bottom) does not play a role.
if (stackingContextMgr)
return stackingContextMgr->getNumZIndices () - 1;
else
return 0;
case OOFStackingIterator::IN_FLOW:
return 0;
case OOFStackingIterator::OOF_REF:
case OOFStackingIterator::OOF_CONT:
return NUM_OOFM - 1;
default:
assertNotReached ();
return 0;
}
}
int OOFAwareWidget::getLastLevelIndex (int majorLevel, int minorLevel)
{
switch (majorLevel) {
case OOFStackingIterator::BACKGROUND:
return 0;
case OOFStackingIterator::SC_BOTTOM:
case OOFStackingIterator::SC_TOP:
if (stackingContextMgr)
return stackingContextMgr->getNumChildSCWidgets () - 1;
else
return 0;
case OOFStackingIterator::IN_FLOW:
// Should be implemented in the sub class.
assertNotReached ();
case OOFStackingIterator::OOF_REF:
// Should be implemented in the sub class (when references are hold).
return 0;
case OOFStackingIterator::OOF_CONT:
if(outOfFlowMgr[minorLevel])
return outOfFlowMgr[minorLevel]->getNumWidgets () - 1;
else
return 0;
default:
assertNotReached ();
return 0;
}
}
int OOFAwareWidget::getAvailWidthOfChild (Widget *child, bool forceValue)
{
if (isWidgetOOF(child)) {
assert (getWidgetOutOfFlowMgr(child) &&
getWidgetOutOfFlowMgr(child)->dealingWithSizeOfChild (child));
return getWidgetOutOfFlowMgr(child)->getAvailWidthOfChild (child,
forceValue);
} else
return Widget::getAvailWidthOfChild (child, forceValue);
}
int OOFAwareWidget::getAvailHeightOfChild (Widget *child, bool forceValue)
{
if (isWidgetOOF(child)) {
assert (getWidgetOutOfFlowMgr(child) &&
getWidgetOutOfFlowMgr(child)->dealingWithSizeOfChild (child));
return getWidgetOutOfFlowMgr(child)->getAvailHeightOfChild (child,
forceValue);
} else
return Widget::getAvailWidthOfChild (child, forceValue);
}
void OOFAwareWidget::removeChild (Widget *child)
{
// Sub classes should implement this method (and Textblock and
// Table do so), so this point is only reached from
// ~OOFAwareWidget, which removes widgets out of flow.
assert (isWidgetOOF (child));
}
Object *OOFAwareWidget::stackingIterator (bool atEnd)
{
return new OOFStackingIterator (this, atEnd);
}
bool OOFAwareWidget::mustBeWidenedToAvailWidth ()
{
// Only used for floats.
assertNotReached ();
return false;
}
void OOFAwareWidget::borderChanged (int y, Widget *vloat)
{
assertNotReached ();
}
void OOFAwareWidget::clearPositionChanged ()
{
assertNotReached ();
}
void OOFAwareWidget::oofSizeChanged (bool extremesChanged)
{
DBG_OBJ_ENTER ("resize", 0, "oofSizeChanged", "%s",
extremesChanged ? "true" : "false");
queueResize (-1, extremesChanged);
// Extremes changes may become also relevant for the children.
if (extremesChanged)
containerSizeChanged ();
DBG_OBJ_LEAVE ();
}
int OOFAwareWidget::getLineBreakWidth ()
{
assertNotReached ();
return 0;
}
bool OOFAwareWidget::isPossibleContainer (int oofmIndex)
{
return oofmIndex != OOFM_FLOATS;
}
bool OOFAwareWidget::isPossibleContainerParent (int oofmIndex)
{
return oofmIndex != OOFM_FLOATS;
}
bool OOFAwareWidget::adjustExtraSpaceWhenCorrectingRequisitionByOOF ()
{
return true;
}
} // namespace oof
} // namespace dw
|