MCPcopy Create free account
hub / github.com/dillo-browser/dillo / scrollTo

Method scrollTo

dw/iterator.cc:98–205  ·  view source on GitHub ↗

* \brief Scrolls the viewport, so that the region between \em it1 and * \em it2 is seen, according to \em hpos and \em vpos. * * The parameters \em start and \em end have the same meaning as in * dw::core::Iterator::getAllocation, \em start refers * to \em it1, while \em end rerers to \em it2. * * If \em it1 and \em it2 point to the same location (see code), only * \em it1 is regarded, and

Source from the content-addressed store, hash-verified

96 * \em it1 is regarded, and both belowstart and belowend refer to it.
97 */
98void Iterator::scrollTo (Iterator *it1, Iterator *it2, int start, int end,
99 HPosition hpos, VPosition vpos)
100{
101 Allocation alloc1, alloc2, alloc;
102 int x1, x2, y1, y2;
103 DeepIterator *eit1, *eit2, *eit3;
104 int curStart, curEnd, cmp;
105 bool atStart;
106
107 if (it1->equals(it2)) {
108 it1->getAllocation (start, end, &alloc);
109 it1->getWidget()->getLayout()->scrollTo (hpos, vpos, alloc.x, alloc.y,
110 alloc.width,
111 alloc.ascent + alloc.descent);
112 } else {
113 // First, determine the rectangle all iterators from it1 and it2
114 // allocate, i.e. the smallest rectangle containing all allocations of
115 // these iterators.
116 eit1 = new DeepIterator (it1);
117 eit2 = new DeepIterator (it2);
118
119 x1 = INT_MAX;
120 x2 = INT_MIN;
121 y1 = INT_MAX;
122 y2 = INT_MIN;
123
124 for (atStart = true, eit3 = (DeepIterator*)eit1->clone ();
125 (cmp = eit3->compareTo (eit2)) <= 0;
126 eit3->next (), atStart = false) {
127 if (atStart)
128 curStart = start;
129 else
130 curStart = 0;
131
132 if (cmp == 0)
133 curEnd = end;
134 else
135 curEnd = INT_MAX;
136
137 eit3->getAllocation (curStart, curEnd, &alloc);
138 x1 = misc::min (x1, alloc.x);
139 x2 = misc::max (x2, alloc.x + alloc.width);
140 y1 = misc::min (y1, alloc.y);
141 y2 = misc::max (y2, alloc.y + alloc.ascent + alloc.descent);
142 }
143
144 delete eit3;
145 delete eit2;
146 delete eit1;
147
148 it1->getAllocation (start, INT_MAX, &alloc1);
149 it2->getAllocation (0, end, &alloc2);
150
151 if (alloc1.x > alloc2.x) {
152 //
153 // This is due to a line break within the region. When the line is
154 // longer than the viewport, and the region is actually quite short,
155 // the user would not see anything of the region, as in this figure

Callers

nothing calls this directly

Calls 11

minFunction · 0.85
maxFunction · 0.85
getUsesViewportMethod · 0.80
getWidthViewportMethod · 0.80
getHeightViewportMethod · 0.80
equalsMethod · 0.45
getAllocationMethod · 0.45
getWidgetMethod · 0.45
cloneMethod · 0.45
compareToMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected