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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>Dillo: Size requisitions depending on positions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="https://www.dillo.org/dw/html/jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Dillo
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.8 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Size requisitions depending on positions </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><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: <a class="el" href="dw-widget-sizes.html">Sizes of Dillo Widgets</a>, <a class="el" href="dw-grows.html">GROWS - Grand Redesign Of Widget Sizes</a>, and <b>Size requisitions depending on positions</b> (this document).</div><h1>Motivation </h1>
<p>As described in <a class="el" href="dw-out-of-flow.html">Handling Elements Out Of Flow</a> (<em>The sizeRequest/sizeAllocate problem</em>), 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 <a class="el" href="classdw_1_1core_1_1Widget.html#ac00e44ccde79daf2b90247c352de67ef" title="This method should be called, when a widget changes its size. ">dw::core::Widget::queueResize</a>. In this document, an alternative approach is presented.</p>
<div style="border: 2px solid #ffff00; margin: 1em 0; padding: 0.5em 1em;
background-color: #ffffe0">This approach works very well for floats, but not for positioned elements, which means that calling <a class="el" href="classdw_1_1core_1_1Widget.html#ac00e44ccde79daf2b90247c352de67ef" title="This method should be called, when a widget changes its size. ">dw::core::Widget::queueResize</a> is still needed for the latter. On the other hand, <a class="el" href="classdw_1_1oof_1_1OOFFloatsMgr.html" title="OutOfFlowMgr implementation dealing with floats. ">dw::oof::OOFFloatsMgr</a> (which is much more complex than <a class="el" href="classdw_1_1oof_1_1OOFPositionedMgr.html">dw::oof::OOFPositionedMgr</a>) can be simplified quite much.</div><h1>General Idea </h1>
<p>A widget size may depend on the position relative to an ancestor widget. If a widget wants to get the size of a child widget, it should:</p>
<ol type="1">
<li>call the new methods <a class="el" href="classdw_1_1core_1_1Widget.html#acc72d6e885356f570fa97c34f462c87d" title="See Sizes of Dillo Widgets (or Size requisitions depending on positions). ">dw::core::Widget::numSizeRequestReferences</a> and <a class="el" href="classdw_1_1core_1_1Widget.html#ab3eaa8ec73207079489f0509205a24a7" title="See Sizes of Dillo Widgets (or Size requisitions depending on positions). ">dw::core::Widget::sizeRequestReference</a>, which return all widgets relative to which the child's position must be calculated;</li>
<li>call <a class="el" href="classdw_1_1core_1_1Widget.html#a34dcfd744c6eec49fa87baaa8591896e" title="This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed...">dw::core::Widget::sizeRequest</a> with the positions relative to these widgets.</li>
</ol>
<div style="border: 2px solid #ffff00; margin: 1em 0;
padding: 0.5em 1em; background-color: #ffffe0">It is not sufficient to work with <em>absolute</em> positions, since there may be an interruption passing the positions so that absolute positions are often not known.</div><p>All positions passed to <a class="el" href="classdw_1_1core_1_1Widget.html#a34dcfd744c6eec49fa87baaa8591896e" title="This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed...">dw::core::Widget::sizeRequest</a> must constitute the position at which this child will be allocated.</p>
<p>There are situations where the parent widget is unable to determine these positions before the size is known. An example: a textblock widget cannot determine the positions 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.</p>
<p>This may result in a conflict, when the size of an inline widget depends on positions. Generally, the only widget whose size depends on positions is <a class="el" href="classdw_1_1Textblock.html" title="A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs. ">dw::Textblock</a> (the size will depend on the positions within its oof container, see <a class="el" href="dw-out-of-flow.html">Handling Elements Out Of Flow</a>), so this conflict occurs with inline blocks.</p>
<p>This conflict is handled in different ways:</p>
<ol type="1">
<li>Fortunately, this case is irrelevat for floats: an inline block constitutes its own floats container, so that there is no dependance on a position within another widget.</li>
<li>For positioned elements, this case is relevant, since an inline block is in most cases not a container for positioned elements. In this case, a generator will call the methods <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a5eef72177348d71e80ba1feadc8313e2">dw::oof::OutOfFlowMgr::tellIncompletePosition1</a> and <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a6aa1b6881d307362e40d009186f3fb56">dw::oof::OutOfFlowMgr::tellIncompletePosition2</a>, instead of dw::oof::OutOfFlowMgr::tellPosition and <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a9610e1f60895d4199a45e7c03ed98116" title="Called after tellPosition1. ">dw::oof::OutOfFlowMgr::tellPosition2</a>, respectively. (Since this case is irrelevant for floats, <a class="el" href="classdw_1_1oof_1_1OOFFloatsMgr.html#ad14cb4af825d4b839d8d4ef36878203f">dw::oof::OOFFloatsMgr::tellIncompletePosition1</a> and <a class="el" href="classdw_1_1oof_1_1OOFFloatsMgr.html#a3d54b7f2ebe847521d8723506ae36064">dw::oof::OOFFloatsMgr::tellIncompletePosition2</a> are not implemented but simply abort.)</li>
</ol>
<p>(This is not (yet) considered for borders: borders are only relevant for floats, but conflicts do not occur for floats.)</p>
<h2>Extremes </h2>
<p>Extremes may depend on the position in an analogue way, see:</p>
<ul>
<li><a class="el" href="classdw_1_1core_1_1Widget.html#ab1ad7db0e636133879a8c86cd5b8adc5" title="See Sizes of Dillo Widgets (or Size requisitions depending on positions). ">dw::core::Widget::numGetExtremesReferences</a>,</li>
<li><a class="el" href="classdw_1_1core_1_1Widget.html#acd3fcfd5499180df60794d11fd0de632" title="See Sizes of Dillo Widgets (or Size requisitions depending on positions). ">dw::core::Widget::getExtremesReference</a>, and</li>
<li><a class="el" href="classdw_1_1core_1_1Widget.html#aec23092b0cfe5624b9751a59671fe251" title="Wrapper for Widget::getExtremesImpl(). ">dw::core::Widget::getExtremes</a>.</li>
</ul>
<h2>Resizing </h2>
<p>Currently, the size of a widget has to be recalculated when:</p>
<ol type="1">
<li>it has called <a class="el" href="classdw_1_1core_1_1Widget.html#ac00e44ccde79daf2b90247c352de67ef" title="This method should be called, when a widget changes its size. ">dw::core::Widget::queueResize</a>, or</li>
<li>the size of a child widget has to be recalculated.</li>
</ol>
<p>Since for this new approach, the size does not only depend on the size of the children, the second condition must be modified. See beginning of <a class="el" href="classdw_1_1core_1_1Widget.html#a34dcfd744c6eec49fa87baaa8591896e" title="This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed...">dw::core::Widget::sizeRequest</a>.</p>
<p>An implementation may have to consider, this too, especially when implementing incremental resizing (see <a class="el" href="dw-widget-sizes.html">Sizes of Dillo Widgets</a>); see <a class="el" href="classdw_1_1Textblock.html#adb2f79277f25d9e2bb406214ae7af83f">dw::Textblock::sizeRequestImpl</a> as an example.</p>
<p>Regarding changes of the position is not sufficient. Consider this example, where a float size changes as soon as the image is loaded:</p>
<div class="image">
<img src="dw-size-request-pos-01.png" alt="dw-size-request-pos-01.png"/>
</div>
<p>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. Instead, this is handled by <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a974ea12945a52087dce3805515f68819">dw::oof::OutOfFlowMgr::markSizeChange</a> (and likewise <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#ae1162652b80ebdf51c88f3833d71558a">dw::oof::OutOfFlowMgr::markExtremesChange</a>), which is called by the implementation of <code>markSizeChange</code> (or <code>markExtremesChange</code>, respectively) of the OOF container. (See also the end of the comment of <a class="el" href="classdw_1_1oof_1_1OOFAwareWidget.html" title="Base class for widgets which can act as container and generator for widgets out of flow...">dw::oof::OOFAwareWidget</a>.)</p>
<h1>Plan </h1>
<ol type="1">
<li>General design (<a class="el" href="classdw_1_1core_1_1Widget.html#ab3eaa8ec73207079489f0509205a24a7" title="See Sizes of Dillo Widgets (or Size requisitions depending on positions). ">dw::core::Widget::sizeRequestReference</a>, changes to <a class="el" href="classdw_1_1core_1_1Widget.html#a34dcfd744c6eec49fa87baaa8591896e" title="This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed...">dw::core::Widget::sizeRequest</a>). Completed.</li>
<li>Implementation for <a class="el" href="classdw_1_1Textblock.html" title="A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs. ">dw::Textblock</a>. Completed.</li>
<li><p class="startli">Change interface of <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html" title="Represents additional data for OOF containers. ">dw::oof::OutOfFlowMgr</a> (this affects mostly only comments). Completed.</p>
<p class="startli">Affects methods <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a5d252d563e8789b9204b4d202aa8cd16" title="Called before tellPosition2, see there for more. ">dw::oof::OutOfFlowMgr::tellPosition1</a>, <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a9610e1f60895d4199a45e7c03ed98116" title="Called after tellPosition1. ">dw::oof::OutOfFlowMgr::tellPosition2</a>, <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#ad46e01fffe1572e0f58fb9b033d3360d">dw::oof::OutOfFlowMgr::getLeftBorder</a>, <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a56b43123e06f3ca605ba27e99e84e917">dw::oof::OutOfFlowMgr::getRightBorder</a>, <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a2dd96065c4e7481bd171222cc7104d7c">dw::oof::OutOfFlowMgr::hasFloatLeft</a>, <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a2829475e7d522efe0850ea69ab0d1d54">dw::oof::OutOfFlowMgr::hasFloatRight</a>, <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a597e3930f99513843b433770f3773509">dw::oof::OutOfFlowMgr::getLeftFloatHeight</a>, and <a class="el" href="classdw_1_1oof_1_1OutOfFlowMgr.html#a90762a59db89a76912477ba3c4da8bd8">dw::oof::OutOfFlowMgr::getRightFloatHeight</a>.</p>
</li>
<li><p class="startli">Apply step 3 to calls within <a class="el" href="classdw_1_1Textblock.html" title="A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs. ">dw::Textblock</a>. Completed.</p>
<p class="startli"><b>Attention:</b> After this step, and before completing the next steps, the code is inconsistent and so incorrect.</p>
</li>
<li>Implement step 3 for floats (affects <a class="el" href="classdw_1_1oof_1_1OOFFloatsMgr.html" title="OutOfFlowMgr implementation dealing with floats. ">dw::oof::OOFFloatsMgr</a>). <b>MOSTLY COMPLETED.</b></li>
<li>Implement step 3 for positioned elements (affects only <a class="el" href="classdw_1_1oof_1_1OOFPositionedMgr.html">dw::oof::OOFPositionedMgr</a>). <b>INCOMPLETE.</b> (But positioned elements are currently deactivated.)</li>
</ol>
<h1>Issues </h1>
<ul>
<li>Since the signature of <a class="el" href="classdw_1_1core_1_1Widget.html#ac3764607155e58daee03db5cbb76d8e2" title="See Sizes of Dillo Widgets. ">dw::core::Widget::sizeRequestImpl</a> changes quite often during the development of <em>size requisitions depending on positions</em>, a simpler option <a class="el" href="classdw_1_1core_1_1Widget.html#a80bff37480606bf9ff8f3d913e16c8b4" title="Simple variant, to be implemented by widgets with sizes not depending on positions. ">dw::core::Widget::sizeRequestSimpl</a> has been added. May be removed again, after the design is stable.</li>
<li>As an alternative, passing the references may be done in a new method, which is called <em>before</em> <a class="el" href="classdw_1_1core_1_1Widget.html#ac3764607155e58daee03db5cbb76d8e2" title="See Sizes of Dillo Widgets. ">dw::core::Widget::sizeRequestImpl</a>. This makes even more sense, after <a class="el" href="classdw_1_1core_1_1Widget.html#a461b61bd42a01e41ccf258db8673d82f" title="Calculates dw::core::Widget::extraSpace. ">dw::core::Widget::calcExtraSpace</a> and <a class="el" href="classdw_1_1core_1_1Widget.html#a87e7d6f31595a2628cab9253c241191d" title="The actual implementation for calculating dw::core::Widget::extraSpace. ">dw::core::Widget::calcExtraSpaceImpl</a> have been extended by references.</li>
<li>There may be inconsistencies for widget styles; see <a href="http://flpsed.org/hgweb/dillo_grows/rev/f797436687fe">revision f797436687fe</a> as an example for a fix. Perhaps a different approach, where breaks are added, <em>if <code>display</code> has the value <code>block</code></em> (or analogue), will work better. </li>
</ul>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat May 28 2016 11:47:43 for Dillo by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.8
</small></address>
</body>
</html>
|