summaryrefslogtreecommitdiff
path: root/devdoc/dw-size-request-pos.doc
blob: dc497d002b6503d52383690709b17047ec045f2d (plain)
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
/** \page dw-size-request-pos Size requisitions depending on positions

<div style="border: 2px solid #ffff00; margin: 1em 0;
  padding: 0.5em 1em; background-color: #ffffe0">The complex "widget
  sizes" is currently divided into three documents: \ref
  dw-widget-sizes, \ref dw-grows, and **Size requisitions depending on
  positions** (this document). </div>

Motivation
==========

As described in \ref dw-out-of-flow (*The sizeRequest/sizeAllocate
problem*), the principle that the size of a widget depends only on the
sizes of its children causes some problems with floats; the current
solution is a frequent correction by calling
dw::core::Widget::queueResize. In this document, an alternative
approach is presented.


General Idea
============

A widget size may depend on the position relative to an anchestor
widget. If a widget wants to get the size of a child widget, it should

1. call the new method dw::core::Widget::sizeRequestReference,
   which returns NULL, when the child's size does not depend on the
   position, or a widget relative to which the child's position must
   be calculated;
2. call dw::core::Widget::sizeRequest with the position relative to
   this widget.

The position passed to dw::core::Widget::sizeRequest must be the
position at which this child will be allocated.

There are situations where the parent widget is unable to determine
this position before the size is known. An example: a textblock widget
cannot determine the position of an inline widget (like an image, or
an inline block) before the line is finished; on the other hand,
finishing the line depends on knowing the sizes of the inline widgets.

This may result in a conflict, when the size of an inline widgets
depends on the position. Fortunately, this is not the case in dillo:
the only widget whose size depends on the position is dw::Textblock
(the size will depend on the position within its floats container); but
an inline blocks constitute its own floats container, so that there is
no dependance on a position within another widget.

Generally, this case should be handled by providing a fallback
strategy. (TODO: How does this look like? The widget is forced to
calculate its size independant of the position?)

Resizing
--------
Currently, the size of a widget has to be recalculated, when

1. it has called dw::core::Widget::queueResize, or
2. the size of a child widget has to be recalculated.

Since for this new approach, the size does not only depend on the size
of the children, the second condition must be modified. However,
regarding changes of the position is not sufficient. Consider this
example, where a float size changes as soon as the image is loaded:

\image html dw-size-request-pos-01.png

The second paragraph ("A longer paragraph" ...) stays at the same
position, both absolute and relative to the float container, but has
to be rewrapped because of the float.

(TODO: A detailed design is yet to de developed.)


Plan
====

1. General design (dw::core::Widget::sizeRequestReference, changes to
   dw::core::Widget::sizeRequest). **COMPLETED.**

2. Implementation for dw::Textblock. **COMPLETED** (except for some bugs).

3. Change interface of dw::oof::OutOfFlowMgr (this affects mostly
   only comments). **COMPLETED.**

   Affects methods dw::oof::OutOfFlowMgr::tellPosition1,
   dw::oof::OutOfFlowMgr::tellPosition2,
   dw::oof::OutOfFlowMgr::getLeftBorder,
   dw::oof::OutOfFlowMgr::getRightBorder,
   dw::oof::OutOfFlowMgr::hasFloatLeft,
   dw::oof::OutOfFlowMgr::hasFloatRight,
   dw::oof::OutOfFlowMgr::getLeftFloatHeight, and
   dw::oof::OutOfFlowMgr::getRightFloatHeight.

4. Apply step 3 to calls within dw::Textblock. **COMPLETED.**

   <b>Attention:</b> After this step, and before completing the next
   steps, the code is inconsistend and so incorrect.

5. Implement step 3 for floats (affects dw::oof:OOFFloatsMgr).
   *INCOMPLETE.*

6. Implement step 3 for positioned elements (affects only
   dw::oof:OOFPositionedMgr). *INCOMPLETE.*

*/