author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 03 May 2010 13:17:34 +0300 | |
changeset 19 | fcece45ef507 |
parent 18 | 2f34d5167611 |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
|
3 |
* |
|
4 |
* Redistribution and use in source and binary forms, with or without |
|
5 |
* modification, are permitted provided that the following conditions |
|
6 |
* are met: |
|
7 |
* 1. Redistributions of source code must retain the above copyright |
|
8 |
* notice, this list of conditions and the following disclaimer. |
|
9 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
10 |
* notice, this list of conditions and the following disclaimer in the |
|
11 |
* documentation and/or other materials provided with the distribution. |
|
12 |
* |
|
13 |
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
|
14 |
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
15 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
16 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
|
17 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
18 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
19 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
20 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
21 |
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
22 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
23 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
24 |
*/ |
|
25 |
||
26 |
#include "config.h" |
|
27 |
#include "ScrollView.h" |
|
28 |
||
29 |
#include "GraphicsContext.h" |
|
30 |
#include "HostWindow.h" |
|
31 |
#include "PlatformMouseEvent.h" |
|
32 |
#include "PlatformWheelEvent.h" |
|
33 |
#include "Scrollbar.h" |
|
34 |
#include "ScrollbarTheme.h" |
|
35 |
#include <wtf/StdLibExtras.h> |
|
36 |
||
37 |
using std::max; |
|
38 |
||
39 |
namespace WebCore { |
|
40 |
||
41 |
ScrollView::ScrollView() |
|
42 |
: m_horizontalScrollbarMode(ScrollbarAuto) |
|
43 |
, m_verticalScrollbarMode(ScrollbarAuto) |
|
44 |
, m_prohibitsScrolling(false) |
|
45 |
, m_canBlitOnScroll(true) |
|
46 |
, m_scrollbarsAvoidingResizer(0) |
|
47 |
, m_scrollbarsSuppressed(false) |
|
48 |
, m_inUpdateScrollbars(false) |
|
49 |
, m_updateScrollbarsPass(0) |
|
50 |
, m_drawPanScrollIcon(false) |
|
51 |
, m_useFixedLayout(false) |
|
52 |
{ |
|
53 |
platformInit(); |
|
54 |
} |
|
55 |
||
56 |
ScrollView::~ScrollView() |
|
57 |
{ |
|
58 |
platformDestroy(); |
|
59 |
} |
|
60 |
||
61 |
void ScrollView::addChild(PassRefPtr<Widget> prpChild) |
|
62 |
{ |
|
63 |
Widget* child = prpChild.get(); |
|
64 |
ASSERT(child != this && !child->parent()); |
|
65 |
child->setParent(this); |
|
66 |
m_children.add(prpChild); |
|
67 |
if (child->platformWidget()) |
|
68 |
platformAddChild(child); |
|
69 |
} |
|
70 |
||
71 |
void ScrollView::removeChild(Widget* child) |
|
72 |
{ |
|
73 |
ASSERT(child->parent() == this); |
|
74 |
child->setParent(0); |
|
75 |
m_children.remove(child); |
|
76 |
if (child->platformWidget()) |
|
77 |
platformRemoveChild(child); |
|
78 |
} |
|
79 |
||
80 |
void ScrollView::setHasHorizontalScrollbar(bool hasBar) |
|
81 |
{ |
|
82 |
if (hasBar && !m_horizontalScrollbar) { |
|
83 |
m_horizontalScrollbar = createScrollbar(HorizontalScrollbar); |
|
84 |
addChild(m_horizontalScrollbar.get()); |
|
85 |
m_horizontalScrollbar->styleChanged(); |
|
86 |
} else if (!hasBar && m_horizontalScrollbar) { |
|
87 |
removeChild(m_horizontalScrollbar.get()); |
|
88 |
m_horizontalScrollbar = 0; |
|
89 |
} |
|
90 |
} |
|
91 |
||
92 |
void ScrollView::setHasVerticalScrollbar(bool hasBar) |
|
93 |
{ |
|
94 |
if (hasBar && !m_verticalScrollbar) { |
|
95 |
m_verticalScrollbar = createScrollbar(VerticalScrollbar); |
|
96 |
addChild(m_verticalScrollbar.get()); |
|
97 |
m_verticalScrollbar->styleChanged(); |
|
98 |
} else if (!hasBar && m_verticalScrollbar) { |
|
99 |
removeChild(m_verticalScrollbar.get()); |
|
100 |
m_verticalScrollbar = 0; |
|
101 |
} |
|
102 |
} |
|
103 |
||
104 |
#if !PLATFORM(GTK) |
|
105 |
PassRefPtr<Scrollbar> ScrollView::createScrollbar(ScrollbarOrientation orientation) |
|
106 |
{ |
|
107 |
return Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar); |
|
108 |
} |
|
109 |
||
110 |
void ScrollView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode) |
|
111 |
{ |
|
112 |
if (horizontalMode == horizontalScrollbarMode() && verticalMode == verticalScrollbarMode()) |
|
113 |
return; |
|
114 |
m_horizontalScrollbarMode = horizontalMode; |
|
115 |
m_verticalScrollbarMode = verticalMode; |
|
116 |
if (platformWidget()) |
|
117 |
platformSetScrollbarModes(); |
|
118 |
else |
|
119 |
updateScrollbars(scrollOffset()); |
|
120 |
} |
|
121 |
#endif |
|
122 |
||
123 |
void ScrollView::scrollbarModes(ScrollbarMode& horizontalMode, ScrollbarMode& verticalMode) const |
|
124 |
{ |
|
125 |
if (platformWidget()) { |
|
126 |
platformScrollbarModes(horizontalMode, verticalMode); |
|
127 |
return; |
|
128 |
} |
|
129 |
horizontalMode = m_horizontalScrollbarMode; |
|
130 |
verticalMode = m_verticalScrollbarMode; |
|
131 |
} |
|
132 |
||
133 |
void ScrollView::setCanHaveScrollbars(bool canScroll) |
|
134 |
{ |
|
135 |
ScrollbarMode newHorizontalMode; |
|
136 |
ScrollbarMode newVerticalMode; |
|
137 |
||
138 |
scrollbarModes(newHorizontalMode, newVerticalMode); |
|
139 |
||
140 |
if (canScroll && newVerticalMode == ScrollbarAlwaysOff) |
|
141 |
newVerticalMode = ScrollbarAuto; |
|
142 |
else if (!canScroll) |
|
143 |
newVerticalMode = ScrollbarAlwaysOff; |
|
144 |
||
145 |
if (canScroll && newHorizontalMode == ScrollbarAlwaysOff) |
|
146 |
newHorizontalMode = ScrollbarAuto; |
|
147 |
else if (!canScroll) |
|
148 |
newHorizontalMode = ScrollbarAlwaysOff; |
|
149 |
||
150 |
setScrollbarModes(newHorizontalMode, newVerticalMode); |
|
151 |
} |
|
152 |
||
153 |
void ScrollView::setCanBlitOnScroll(bool b) |
|
154 |
{ |
|
155 |
if (platformWidget()) { |
|
156 |
platformSetCanBlitOnScroll(b); |
|
157 |
return; |
|
158 |
} |
|
159 |
||
160 |
m_canBlitOnScroll = b; |
|
161 |
} |
|
162 |
||
163 |
bool ScrollView::canBlitOnScroll() const |
|
164 |
{ |
|
165 |
if (platformWidget()) |
|
166 |
return platformCanBlitOnScroll(); |
|
167 |
||
168 |
return m_canBlitOnScroll; |
|
169 |
} |
|
170 |
||
171 |
#if !PLATFORM(GTK) |
|
172 |
IntRect ScrollView::visibleContentRect(bool includeScrollbars) const |
|
173 |
{ |
|
174 |
if (platformWidget()) |
|
175 |
return platformVisibleContentRect(includeScrollbars); |
|
176 |
return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()), |
|
177 |
IntSize(max(0, width() - (verticalScrollbar() && !includeScrollbars ? verticalScrollbar()->width() : 0)), |
|
178 |
max(0, height() - (horizontalScrollbar() && !includeScrollbars ? horizontalScrollbar()->height() : 0)))); |
|
179 |
} |
|
180 |
#endif |
|
181 |
||
182 |
int ScrollView::layoutWidth() const |
|
183 |
{ |
|
184 |
return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? visibleWidth() : m_fixedLayoutSize.width(); |
|
185 |
} |
|
186 |
||
187 |
int ScrollView::layoutHeight() const |
|
188 |
{ |
|
189 |
return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? visibleHeight() : m_fixedLayoutSize.height(); |
|
190 |
} |
|
191 |
||
192 |
IntSize ScrollView::fixedLayoutSize() const |
|
193 |
{ |
|
194 |
return m_fixedLayoutSize; |
|
195 |
} |
|
196 |
||
197 |
void ScrollView::setFixedLayoutSize(const IntSize& newSize) |
|
198 |
{ |
|
199 |
if (fixedLayoutSize() == newSize) |
|
200 |
return; |
|
201 |
m_fixedLayoutSize = newSize; |
|
202 |
updateScrollbars(scrollOffset()); |
|
203 |
} |
|
204 |
||
205 |
bool ScrollView::useFixedLayout() const |
|
206 |
{ |
|
207 |
return m_useFixedLayout; |
|
208 |
} |
|
209 |
||
210 |
void ScrollView::setUseFixedLayout(bool enable) |
|
211 |
{ |
|
212 |
if (useFixedLayout() == enable) |
|
213 |
return; |
|
214 |
m_useFixedLayout = enable; |
|
215 |
updateScrollbars(scrollOffset()); |
|
216 |
} |
|
217 |
||
218 |
IntSize ScrollView::contentsSize() const |
|
219 |
{ |
|
220 |
if (platformWidget()) |
|
221 |
return platformContentsSize(); |
|
222 |
return m_contentsSize; |
|
223 |
} |
|
224 |
||
225 |
void ScrollView::setContentsSize(const IntSize& newSize) |
|
226 |
{ |
|
227 |
if (contentsSize() == newSize) |
|
228 |
return; |
|
229 |
m_contentsSize = newSize; |
|
230 |
if (platformWidget()) |
|
231 |
platformSetContentsSize(); |
|
232 |
else |
|
233 |
updateScrollbars(scrollOffset()); |
|
234 |
} |
|
235 |
||
236 |
IntPoint ScrollView::maximumScrollPosition() const |
|
237 |
{ |
|
238 |
IntSize maximumOffset = contentsSize() - visibleContentRect().size(); |
|
239 |
maximumOffset.clampNegativeToZero(); |
|
240 |
return IntPoint(maximumOffset.width(), maximumOffset.height()); |
|
241 |
} |
|
242 |
||
243 |
void ScrollView::valueChanged(Scrollbar* scrollbar) |
|
244 |
{ |
|
245 |
// Figure out if we really moved. |
|
246 |
IntSize newOffset = m_scrollOffset; |
|
247 |
if (scrollbar) { |
|
248 |
if (scrollbar->orientation() == HorizontalScrollbar) |
|
249 |
newOffset.setWidth(scrollbar->value()); |
|
250 |
else if (scrollbar->orientation() == VerticalScrollbar) |
|
251 |
newOffset.setHeight(scrollbar->value()); |
|
252 |
} |
|
253 |
||
254 |
IntSize scrollDelta = newOffset - m_scrollOffset; |
|
255 |
if (scrollDelta == IntSize()) |
|
256 |
return; |
|
257 |
m_scrollOffset = newOffset; |
|
258 |
||
259 |
if (scrollbarsSuppressed()) |
|
260 |
return; |
|
261 |
||
262 |
scrollContents(scrollDelta); |
|
263 |
} |
|
264 |
||
265 |
void ScrollView::scrollRectIntoViewRecursively(const IntRect& r) |
|
266 |
{ |
|
267 |
// FIXME: This method is not transform-aware. It should just be moved to FrameView so that an accurate |
|
268 |
// position for the child view can be determined. |
|
269 |
IntRect rect = r; |
|
270 |
ScrollView* view = this; |
|
271 |
while (view) { |
|
272 |
if (view->prohibitsScrolling()) // Allow the views to scroll into view recursively until we hit one that prohibits scrolling. |
|
273 |
return; |
|
274 |
view->setScrollPosition(rect.location()); |
|
275 |
rect.move(view->x() - view->scrollOffset().width(), view->y() - view->scrollOffset().height()); |
|
276 |
if (view->parent()) |
|
277 |
rect.intersect(view->frameRect()); |
|
278 |
view = view->parent(); |
|
279 |
} |
|
280 |
||
281 |
// We may be embedded inside some containing platform scroll view that we don't manage. This is the case |
|
282 |
// in Mail.app on OS X, for example, where the WebKit view for message bodies is inside a Cocoa NSScrollView |
|
283 |
// that contains both it and message headers. Let the HostWindow know about this scroll so that it can pass the message |
|
284 |
// on up the view chain. |
|
285 |
// This rect is not clamped, since Mail actually relies on receiving an unclamped rect with negative coordinates in order to |
|
286 |
// expose the headers. |
|
287 |
if (hostWindow()) |
|
288 |
hostWindow()->scrollRectIntoView(rect, this); |
|
289 |
} |
|
290 |
||
291 |
void ScrollView::setScrollPosition(const IntPoint& scrollPoint) |
|
292 |
{ |
|
293 |
if (prohibitsScrolling()) |
|
294 |
return; |
|
295 |
||
296 |
if (platformWidget()) { |
|
297 |
platformSetScrollPosition(scrollPoint); |
|
298 |
return; |
|
299 |
} |
|
300 |
||
301 |
IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); |
|
302 |
newScrollPosition.clampNegativeToZero(); |
|
303 |
||
304 |
if (newScrollPosition == scrollPosition()) |
|
305 |
return; |
|
306 |
||
307 |
updateScrollbars(IntSize(newScrollPosition.x(), newScrollPosition.y())); |
|
308 |
} |
|
309 |
||
310 |
bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity) |
|
311 |
{ |
|
312 |
if (platformWidget()) |
|
313 |
return platformScroll(direction, granularity); |
|
314 |
||
315 |
if (direction == ScrollUp || direction == ScrollDown) { |
|
316 |
if (m_verticalScrollbar) |
|
317 |
return m_verticalScrollbar->scroll(direction, granularity); |
|
318 |
} else { |
|
319 |
if (m_horizontalScrollbar) |
|
320 |
return m_horizontalScrollbar->scroll(direction, granularity); |
|
321 |
} |
|
322 |
return false; |
|
323 |
} |
|
324 |
||
325 |
static const unsigned cMaxUpdateScrollbarsPass = 2; |
|
326 |
||
327 |
void ScrollView::updateScrollbars(const IntSize& desiredOffset) |
|
328 |
{ |
|
329 |
if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget()) |
|
330 |
return; |
|
331 |
||
332 |
// If we came in here with the view already needing a layout, then go ahead and do that |
|
333 |
// first. (This will be the common case, e.g., when the page changes due to window resizing for example). |
|
334 |
// This layout will not re-enter updateScrollbars and does not count towards our max layout pass total. |
|
335 |
if (!m_scrollbarsSuppressed) { |
|
336 |
m_inUpdateScrollbars = true; |
|
337 |
visibleContentsResized(); |
|
338 |
m_inUpdateScrollbars = false; |
|
339 |
} |
|
340 |
||
341 |
bool hasHorizontalScrollbar = m_horizontalScrollbar; |
|
342 |
bool hasVerticalScrollbar = m_verticalScrollbar; |
|
343 |
||
344 |
bool newHasHorizontalScrollbar = hasHorizontalScrollbar; |
|
345 |
bool newHasVerticalScrollbar = hasVerticalScrollbar; |
|
346 |
||
347 |
ScrollbarMode hScroll = m_horizontalScrollbarMode; |
|
348 |
ScrollbarMode vScroll = m_verticalScrollbarMode; |
|
349 |
||
350 |
if (hScroll != ScrollbarAuto) |
|
351 |
newHasHorizontalScrollbar = (hScroll == ScrollbarAlwaysOn); |
|
352 |
if (vScroll != ScrollbarAuto) |
|
353 |
newHasVerticalScrollbar = (vScroll == ScrollbarAlwaysOn); |
|
354 |
||
355 |
if (m_scrollbarsSuppressed || (hScroll != ScrollbarAuto && vScroll != ScrollbarAuto)) { |
|
356 |
if (hasHorizontalScrollbar != newHasHorizontalScrollbar) |
|
357 |
setHasHorizontalScrollbar(newHasHorizontalScrollbar); |
|
358 |
if (hasVerticalScrollbar != newHasVerticalScrollbar) |
|
359 |
setHasVerticalScrollbar(newHasVerticalScrollbar); |
|
360 |
} else { |
|
361 |
bool sendContentResizedNotification = false; |
|
362 |
||
363 |
IntSize docSize = contentsSize(); |
|
364 |
IntSize frameSize = frameRect().size(); |
|
365 |
||
366 |
if (hScroll == ScrollbarAuto) { |
|
367 |
newHasHorizontalScrollbar = docSize.width() > visibleWidth(); |
|
368 |
if (newHasHorizontalScrollbar && !m_updateScrollbarsPass && docSize.width() <= frameSize.width() && docSize.height() <= frameSize.height()) |
|
369 |
newHasHorizontalScrollbar = false; |
|
370 |
} |
|
371 |
if (vScroll == ScrollbarAuto) { |
|
372 |
newHasVerticalScrollbar = docSize.height() > visibleHeight(); |
|
373 |
if (newHasVerticalScrollbar && !m_updateScrollbarsPass && docSize.width() <= frameSize.width() && docSize.height() <= frameSize.height()) |
|
374 |
newHasVerticalScrollbar = false; |
|
375 |
} |
|
376 |
||
377 |
// If we ever turn one scrollbar off, always turn the other one off too. Never ever |
|
378 |
// try to both gain/lose a scrollbar in the same pass. |
|
379 |
if (!newHasHorizontalScrollbar && hasHorizontalScrollbar && vScroll != ScrollbarAlwaysOn) |
|
380 |
newHasVerticalScrollbar = false; |
|
381 |
if (!newHasVerticalScrollbar && hasVerticalScrollbar && hScroll != ScrollbarAlwaysOn) |
|
382 |
newHasHorizontalScrollbar = false; |
|
383 |
||
384 |
if (hasHorizontalScrollbar != newHasHorizontalScrollbar) { |
|
385 |
setHasHorizontalScrollbar(newHasHorizontalScrollbar); |
|
386 |
sendContentResizedNotification = true; |
|
387 |
} |
|
388 |
||
389 |
if (hasVerticalScrollbar != newHasVerticalScrollbar) { |
|
390 |
setHasVerticalScrollbar(newHasVerticalScrollbar); |
|
391 |
sendContentResizedNotification = true; |
|
392 |
} |
|
393 |
||
394 |
if (sendContentResizedNotification && m_updateScrollbarsPass < cMaxUpdateScrollbarsPass) { |
|
395 |
m_updateScrollbarsPass++; |
|
396 |
contentsResized(); |
|
397 |
visibleContentsResized(); |
|
398 |
IntSize newDocSize = contentsSize(); |
|
399 |
if (newDocSize == docSize) { |
|
400 |
// The layout with the new scroll state had no impact on |
|
401 |
// the document's overall size, so updateScrollbars didn't get called. |
|
402 |
// Recur manually. |
|
403 |
updateScrollbars(desiredOffset); |
|
404 |
} |
|
405 |
m_updateScrollbarsPass--; |
|
406 |
} |
|
407 |
} |
|
408 |
||
409 |
// Set up the range (and page step/line step), but only do this if we're not in a nested call (to avoid |
|
410 |
// doing it multiple times). |
|
411 |
if (m_updateScrollbarsPass) |
|
412 |
return; |
|
413 |
||
414 |
m_inUpdateScrollbars = true; |
|
415 |
IntSize maxScrollPosition(contentsWidth() - visibleWidth(), contentsHeight() - visibleHeight()); |
|
416 |
IntSize scroll = desiredOffset.shrunkTo(maxScrollPosition); |
|
417 |
scroll.clampNegativeToZero(); |
|
418 |
||
419 |
if (m_horizontalScrollbar) { |
|
420 |
int clientWidth = visibleWidth(); |
|
421 |
m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); |
|
422 |
int pageStep = (clientWidth - cAmountToKeepWhenPaging); |
|
423 |
if (pageStep < 0) |
|
424 |
pageStep = clientWidth; |
|
425 |
IntRect oldRect(m_horizontalScrollbar->frameRect()); |
|
426 |
IntRect hBarRect = IntRect(0, |
|
427 |
height() - m_horizontalScrollbar->height(), |
|
428 |
width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0), |
|
429 |
m_horizontalScrollbar->height()); |
|
430 |
m_horizontalScrollbar->setFrameRect(hBarRect); |
|
431 |
if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRect()) |
|
432 |
m_horizontalScrollbar->invalidate(); |
|
433 |
||
434 |
if (m_scrollbarsSuppressed) |
|
435 |
m_horizontalScrollbar->setSuppressInvalidation(true); |
|
436 |
m_horizontalScrollbar->setSteps(cScrollbarPixelsPerLineStep, pageStep); |
|
437 |
m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); |
|
438 |
m_horizontalScrollbar->setValue(scroll.width()); |
|
439 |
if (m_scrollbarsSuppressed) |
|
440 |
m_horizontalScrollbar->setSuppressInvalidation(false); |
|
441 |
} |
|
442 |
||
443 |
if (m_verticalScrollbar) { |
|
444 |
int clientHeight = visibleHeight(); |
|
445 |
m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); |
|
446 |
int pageStep = (clientHeight - cAmountToKeepWhenPaging); |
|
447 |
if (pageStep < 0) |
|
448 |
pageStep = clientHeight; |
|
449 |
IntRect oldRect(m_verticalScrollbar->frameRect()); |
|
450 |
IntRect vBarRect = IntRect(width() - m_verticalScrollbar->width(), |
|
451 |
0, |
|
452 |
m_verticalScrollbar->width(), |
|
453 |
height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0)); |
|
454 |
m_verticalScrollbar->setFrameRect(vBarRect); |
|
455 |
if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect()) |
|
456 |
m_verticalScrollbar->invalidate(); |
|
457 |
||
458 |
if (m_scrollbarsSuppressed) |
|
459 |
m_verticalScrollbar->setSuppressInvalidation(true); |
|
460 |
m_verticalScrollbar->setSteps(cScrollbarPixelsPerLineStep, pageStep); |
|
461 |
m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); |
|
462 |
m_verticalScrollbar->setValue(scroll.height()); |
|
463 |
if (m_scrollbarsSuppressed) |
|
464 |
m_verticalScrollbar->setSuppressInvalidation(false); |
|
465 |
} |
|
466 |
||
467 |
if (hasHorizontalScrollbar != (m_horizontalScrollbar != 0) || hasVerticalScrollbar != (m_verticalScrollbar != 0)) { |
|
468 |
frameRectsChanged(); |
|
469 |
updateScrollCorner(); |
|
470 |
} |
|
471 |
||
472 |
// See if our offset has changed in a situation where we might not have scrollbars. |
|
473 |
// This can happen when editing a body with overflow:hidden and scrolling to reveal selection. |
|
474 |
// It can also happen when maximizing a window that has scrollbars (but the new maximized result |
|
475 |
// does not). |
|
476 |
IntSize scrollDelta = scroll - m_scrollOffset; |
|
477 |
if (scrollDelta != IntSize()) { |
|
478 |
m_scrollOffset = scroll; |
|
479 |
scrollContents(scrollDelta); |
|
480 |
} |
|
481 |
||
482 |
m_inUpdateScrollbars = false; |
|
483 |
} |
|
484 |
||
485 |
const int panIconSizeLength = 16; |
|
486 |
||
487 |
void ScrollView::scrollContents(const IntSize& scrollDelta) |
|
488 |
{ |
|
489 |
if (!hostWindow()) |
|
490 |
return; |
|
491 |
||
492 |
// Since scrolling is double buffered, we will be blitting the scroll view's intersection |
|
493 |
// with the clip rect every time to keep it smooth. |
|
494 |
IntRect clipRect = windowClipRect(); |
|
495 |
IntRect scrollViewRect = convertToContainingWindow(IntRect(0, 0, visibleWidth(), visibleHeight())); |
|
496 |
IntRect updateRect = clipRect; |
|
497 |
updateRect.intersect(scrollViewRect); |
|
498 |
||
499 |
// Invalidate the window (not the backing store). |
|
500 |
hostWindow()->repaint(updateRect, false); |
|
501 |
||
502 |
if (m_drawPanScrollIcon) { |
|
503 |
int panIconDirtySquareSizeLength = 2 * (panIconSizeLength + max(abs(scrollDelta.width()), abs(scrollDelta.height()))); // We only want to repaint what's necessary |
|
504 |
IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x() - (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySquareSizeLength / 2)); |
|
505 |
IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation , IntSize(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength)); |
|
506 |
panScrollIconDirtyRect.intersect(clipRect); |
|
507 |
hostWindow()->repaint(panScrollIconDirtyRect, true); |
|
508 |
} |
|
509 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
if (canBlitOnScroll()) { // The main frame can just blit the WebView window |
0 | 511 |
// FIXME: Find a way to blit subframes without blitting overlapping content |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
512 |
scrollContentsFastPath(-scrollDelta, scrollViewRect, clipRect); |
0 | 513 |
} else { |
514 |
// We need to go ahead and repaint the entire backing store. Do it now before moving the |
|
515 |
// windowed plugins. |
|
516 |
hostWindow()->repaint(updateRect, true, false, true); // Invalidate the backing store and repaint it synchronously |
|
517 |
} |
|
518 |
||
519 |
// This call will move children with native widgets (plugins) and invalidate them as well. |
|
520 |
frameRectsChanged(); |
|
521 |
||
522 |
// Now update the window (which should do nothing but a blit of the backing store's updateRect and so should |
|
523 |
// be very fast). |
|
524 |
hostWindow()->paint(); |
|
525 |
} |
|
526 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
527 |
void ScrollView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
528 |
{ |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
529 |
hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
530 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
531 |
|
0 | 532 |
IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const |
533 |
{ |
|
534 |
IntPoint viewPoint = convertFromContainingWindow(windowPoint); |
|
535 |
return viewPoint + scrollOffset(); |
|
536 |
} |
|
537 |
||
538 |
IntPoint ScrollView::contentsToWindow(const IntPoint& contentsPoint) const |
|
539 |
{ |
|
540 |
IntPoint viewPoint = contentsPoint - scrollOffset(); |
|
541 |
return convertToContainingWindow(viewPoint); |
|
542 |
} |
|
543 |
||
544 |
IntRect ScrollView::windowToContents(const IntRect& windowRect) const |
|
545 |
{ |
|
546 |
IntRect viewRect = convertFromContainingWindow(windowRect); |
|
547 |
viewRect.move(scrollOffset()); |
|
548 |
return viewRect; |
|
549 |
} |
|
550 |
||
551 |
IntRect ScrollView::contentsToWindow(const IntRect& contentsRect) const |
|
552 |
{ |
|
553 |
IntRect viewRect = contentsRect; |
|
554 |
viewRect.move(-scrollOffset()); |
|
555 |
return convertToContainingWindow(viewRect); |
|
556 |
} |
|
557 |
||
558 |
IntRect ScrollView::contentsToScreen(const IntRect& rect) const |
|
559 |
{ |
|
560 |
if (platformWidget()) |
|
561 |
return platformContentsToScreen(rect); |
|
562 |
if (!hostWindow()) |
|
563 |
return IntRect(); |
|
564 |
return hostWindow()->windowToScreen(contentsToWindow(rect)); |
|
565 |
} |
|
566 |
||
567 |
IntPoint ScrollView::screenToContents(const IntPoint& point) const |
|
568 |
{ |
|
569 |
if (platformWidget()) |
|
570 |
return platformScreenToContents(point); |
|
571 |
if (!hostWindow()) |
|
572 |
return IntPoint(); |
|
573 |
return windowToContents(hostWindow()->screenToWindow(point)); |
|
574 |
} |
|
575 |
||
576 |
bool ScrollView::containsScrollbarsAvoidingResizer() const |
|
577 |
{ |
|
578 |
return !m_scrollbarsAvoidingResizer; |
|
579 |
} |
|
580 |
||
581 |
void ScrollView::adjustScrollbarsAvoidingResizerCount(int overlapDelta) |
|
582 |
{ |
|
583 |
int oldCount = m_scrollbarsAvoidingResizer; |
|
584 |
m_scrollbarsAvoidingResizer += overlapDelta; |
|
585 |
if (parent()) |
|
586 |
parent()->adjustScrollbarsAvoidingResizerCount(overlapDelta); |
|
587 |
else if (!scrollbarsSuppressed()) { |
|
588 |
// If we went from n to 0 or from 0 to n and we're the outermost view, |
|
589 |
// we need to invalidate the windowResizerRect(), since it will now need to paint |
|
590 |
// differently. |
|
591 |
if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) || |
|
592 |
(oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) |
|
593 |
invalidateRect(windowResizerRect()); |
|
594 |
} |
|
595 |
} |
|
596 |
||
597 |
void ScrollView::setParent(ScrollView* parentView) |
|
598 |
{ |
|
599 |
if (parentView == parent()) |
|
600 |
return; |
|
601 |
||
602 |
if (m_scrollbarsAvoidingResizer && parent()) |
|
603 |
parent()->adjustScrollbarsAvoidingResizerCount(-m_scrollbarsAvoidingResizer); |
|
604 |
||
605 |
Widget::setParent(parentView); |
|
606 |
||
607 |
if (m_scrollbarsAvoidingResizer && parent()) |
|
608 |
parent()->adjustScrollbarsAvoidingResizerCount(m_scrollbarsAvoidingResizer); |
|
609 |
} |
|
610 |
||
611 |
void ScrollView::setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress) |
|
612 |
{ |
|
613 |
if (suppressed == m_scrollbarsSuppressed) |
|
614 |
return; |
|
615 |
||
616 |
m_scrollbarsSuppressed = suppressed; |
|
617 |
||
618 |
if (platformWidget()) |
|
619 |
platformSetScrollbarsSuppressed(repaintOnUnsuppress); |
|
620 |
else if (repaintOnUnsuppress && !suppressed) { |
|
621 |
if (m_horizontalScrollbar) |
|
622 |
m_horizontalScrollbar->invalidate(); |
|
623 |
if (m_verticalScrollbar) |
|
624 |
m_verticalScrollbar->invalidate(); |
|
625 |
||
626 |
// Invalidate the scroll corner too on unsuppress. |
|
627 |
invalidateRect(scrollCornerRect()); |
|
628 |
} |
|
629 |
} |
|
630 |
||
631 |
Scrollbar* ScrollView::scrollbarAtPoint(const IntPoint& windowPoint) |
|
632 |
{ |
|
633 |
if (platformWidget()) |
|
634 |
return 0; |
|
635 |
||
636 |
IntPoint viewPoint = convertFromContainingWindow(windowPoint); |
|
637 |
if (m_horizontalScrollbar && m_horizontalScrollbar->frameRect().contains(viewPoint)) |
|
638 |
return m_horizontalScrollbar.get(); |
|
639 |
if (m_verticalScrollbar && m_verticalScrollbar->frameRect().contains(viewPoint)) |
|
640 |
return m_verticalScrollbar.get(); |
|
641 |
return 0; |
|
642 |
} |
|
643 |
||
644 |
void ScrollView::wheelEvent(PlatformWheelEvent& e) |
|
645 |
{ |
|
646 |
// We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled. |
|
647 |
#if PLATFORM(WX) |
|
648 |
if (!canHaveScrollbars()) { |
|
649 |
#else |
|
650 |
if (!canHaveScrollbars() || platformWidget()) { |
|
651 |
#endif |
|
652 |
return; |
|
653 |
} |
|
654 |
||
655 |
// Determine how much we want to scroll. If we can move at all, we will accept the event. |
|
656 |
IntSize maxScrollDelta = maximumScrollPosition() - scrollPosition(); |
|
657 |
if ((e.deltaX() < 0 && maxScrollDelta.width() > 0) || |
|
658 |
(e.deltaX() > 0 && scrollOffset().width() > 0) || |
|
659 |
(e.deltaY() < 0 && maxScrollDelta.height() > 0) || |
|
660 |
(e.deltaY() > 0 && scrollOffset().height() > 0)) { |
|
661 |
e.accept(); |
|
662 |
float deltaX = e.deltaX(); |
|
663 |
float deltaY = e.deltaY(); |
|
664 |
if (e.granularity() == ScrollByPageWheelEvent) { |
|
665 |
ASSERT(deltaX == 0); |
|
666 |
bool negative = deltaY < 0; |
|
667 |
deltaY = max(0, visibleHeight() - cAmountToKeepWhenPaging); |
|
668 |
if (negative) |
|
669 |
deltaY = -deltaY; |
|
670 |
} |
|
671 |
scrollBy(IntSize(-deltaX, -deltaY)); |
|
672 |
} |
|
673 |
} |
|
674 |
||
675 |
void ScrollView::setFrameRect(const IntRect& newRect) |
|
676 |
{ |
|
677 |
IntRect oldRect = frameRect(); |
|
678 |
||
679 |
if (newRect == oldRect) |
|
680 |
return; |
|
681 |
||
682 |
Widget::setFrameRect(newRect); |
|
683 |
||
684 |
if (platformWidget()) |
|
685 |
return; |
|
686 |
||
687 |
if (newRect.width() != oldRect.width() || newRect.height() != oldRect.height()) { |
|
688 |
updateScrollbars(m_scrollOffset); |
|
689 |
contentsResized(); |
|
690 |
} |
|
691 |
||
692 |
frameRectsChanged(); |
|
693 |
} |
|
694 |
||
695 |
void ScrollView::frameRectsChanged() |
|
696 |
{ |
|
697 |
if (platformWidget()) |
|
698 |
return; |
|
699 |
||
700 |
HashSet<RefPtr<Widget> >::const_iterator end = m_children.end(); |
|
701 |
for (HashSet<RefPtr<Widget> >::const_iterator current = m_children.begin(); current != end; ++current) |
|
702 |
(*current)->frameRectsChanged(); |
|
703 |
} |
|
704 |
||
705 |
void ScrollView::repaintContentRectangle(const IntRect& rect, bool now) |
|
706 |
{ |
|
707 |
IntRect visibleContent = visibleContentRect(); |
|
708 |
visibleContent.intersect(rect); |
|
709 |
if (visibleContent.isEmpty()) |
|
710 |
return; |
|
711 |
||
712 |
if (platformWidget()) { |
|
713 |
platformRepaintContentRectangle(visibleContent, now); |
|
714 |
return; |
|
715 |
} |
|
716 |
||
717 |
if (hostWindow()) |
|
718 |
hostWindow()->repaint(contentsToWindow(visibleContent), true, now); |
|
719 |
} |
|
720 |
||
721 |
IntRect ScrollView::scrollCornerRect() const |
|
722 |
{ |
|
723 |
IntRect cornerRect; |
|
724 |
||
725 |
if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) { |
|
726 |
cornerRect.unite(IntRect(m_horizontalScrollbar->width(), |
|
727 |
height() - m_horizontalScrollbar->height(), |
|
728 |
width() - m_horizontalScrollbar->width(), |
|
729 |
m_horizontalScrollbar->height())); |
|
730 |
} |
|
731 |
||
732 |
if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) { |
|
733 |
cornerRect.unite(IntRect(width() - m_verticalScrollbar->width(), |
|
734 |
m_verticalScrollbar->height(), |
|
735 |
m_verticalScrollbar->width(), |
|
736 |
height() - m_verticalScrollbar->height())); |
|
737 |
} |
|
738 |
||
739 |
return cornerRect; |
|
740 |
} |
|
741 |
||
742 |
void ScrollView::updateScrollCorner() |
|
743 |
{ |
|
744 |
} |
|
745 |
||
746 |
void ScrollView::paintScrollCorner(GraphicsContext* context, const IntRect& cornerRect) |
|
747 |
{ |
|
748 |
ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, cornerRect); |
|
749 |
} |
|
750 |
||
751 |
void ScrollView::paintScrollbars(GraphicsContext* context, const IntRect& rect) |
|
752 |
{ |
|
753 |
if (m_horizontalScrollbar) |
|
754 |
m_horizontalScrollbar->paint(context, rect); |
|
755 |
if (m_verticalScrollbar) |
|
756 |
m_verticalScrollbar->paint(context, rect); |
|
757 |
||
758 |
paintScrollCorner(context, scrollCornerRect()); |
|
759 |
} |
|
760 |
||
761 |
void ScrollView::paintPanScrollIcon(GraphicsContext* context) |
|
762 |
{ |
|
763 |
DEFINE_STATIC_LOCAL(Image*, panScrollIcon, (Image::loadPlatformResource("panIcon").releaseRef())); |
|
764 |
context->drawImage(panScrollIcon, m_panScrollIconPoint); |
|
765 |
} |
|
766 |
||
767 |
void ScrollView::paint(GraphicsContext* context, const IntRect& rect) |
|
768 |
{ |
|
769 |
if (platformWidget()) { |
|
770 |
Widget::paint(context, rect); |
|
771 |
return; |
|
772 |
} |
|
773 |
||
774 |
if (context->paintingDisabled() && !context->updatingControlTints()) |
|
775 |
return; |
|
776 |
||
777 |
IntRect documentDirtyRect = rect; |
|
778 |
documentDirtyRect.intersect(frameRect()); |
|
779 |
||
780 |
context->save(); |
|
781 |
||
782 |
context->translate(x(), y()); |
|
783 |
documentDirtyRect.move(-x(), -y()); |
|
784 |
||
785 |
context->translate(-scrollX(), -scrollY()); |
|
786 |
documentDirtyRect.move(scrollX(), scrollY()); |
|
787 |
||
788 |
context->clip(visibleContentRect()); |
|
789 |
||
790 |
paintContents(context, documentDirtyRect); |
|
791 |
||
792 |
context->restore(); |
|
793 |
||
794 |
// Now paint the scrollbars. |
|
795 |
if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar)) { |
|
796 |
context->save(); |
|
797 |
IntRect scrollViewDirtyRect = rect; |
|
798 |
scrollViewDirtyRect.intersect(frameRect()); |
|
799 |
context->translate(x(), y()); |
|
800 |
scrollViewDirtyRect.move(-x(), -y()); |
|
801 |
||
802 |
paintScrollbars(context, scrollViewDirtyRect); |
|
803 |
||
804 |
context->restore(); |
|
805 |
} |
|
806 |
||
807 |
// Paint the panScroll Icon |
|
808 |
if (m_drawPanScrollIcon) |
|
809 |
paintPanScrollIcon(context); |
|
810 |
} |
|
811 |
||
812 |
bool ScrollView::isPointInScrollbarCorner(const IntPoint& windowPoint) |
|
813 |
{ |
|
814 |
if (!scrollbarCornerPresent()) |
|
815 |
return false; |
|
816 |
||
817 |
IntPoint viewPoint = convertFromContainingWindow(windowPoint); |
|
818 |
||
819 |
if (m_horizontalScrollbar) { |
|
820 |
int horizontalScrollbarYMin = m_horizontalScrollbar->frameRect().y(); |
|
821 |
int horizontalScrollbarYMax = m_horizontalScrollbar->frameRect().y() + m_horizontalScrollbar->frameRect().height(); |
|
822 |
int horizontalScrollbarXMin = m_horizontalScrollbar->frameRect().x() + m_horizontalScrollbar->frameRect().width(); |
|
823 |
||
824 |
return viewPoint.y() > horizontalScrollbarYMin && viewPoint.y() < horizontalScrollbarYMax && viewPoint.x() > horizontalScrollbarXMin; |
|
825 |
} |
|
826 |
||
827 |
int verticalScrollbarXMin = m_verticalScrollbar->frameRect().x(); |
|
828 |
int verticalScrollbarXMax = m_verticalScrollbar->frameRect().x() + m_verticalScrollbar->frameRect().width(); |
|
829 |
int verticalScrollbarYMin = m_verticalScrollbar->frameRect().y() + m_verticalScrollbar->frameRect().height(); |
|
830 |
||
831 |
return viewPoint.x() > verticalScrollbarXMin && viewPoint.x() < verticalScrollbarXMax && viewPoint.y() > verticalScrollbarYMin; |
|
832 |
} |
|
833 |
||
834 |
bool ScrollView::scrollbarCornerPresent() const |
|
835 |
{ |
|
836 |
return (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) || |
|
837 |
(m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0); |
|
838 |
} |
|
839 |
||
840 |
IntRect ScrollView::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntRect& localRect) const |
|
841 |
{ |
|
842 |
// Scrollbars won't be transformed within us |
|
843 |
IntRect newRect = localRect; |
|
844 |
newRect.move(scrollbar->x(), scrollbar->y()); |
|
845 |
return newRect; |
|
846 |
} |
|
847 |
||
848 |
IntRect ScrollView::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntRect& parentRect) const |
|
849 |
{ |
|
850 |
IntRect newRect = parentRect; |
|
851 |
// Scrollbars won't be transformed within us |
|
852 |
newRect.move(-scrollbar->x(), -scrollbar->y()); |
|
853 |
return newRect; |
|
854 |
} |
|
855 |
||
856 |
// FIXME: test these on windows |
|
857 |
IntPoint ScrollView::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntPoint& localPoint) const |
|
858 |
{ |
|
859 |
// Scrollbars won't be transformed within us |
|
860 |
IntPoint newPoint = localPoint; |
|
861 |
newPoint.move(scrollbar->x(), scrollbar->y()); |
|
862 |
return newPoint; |
|
863 |
} |
|
864 |
||
865 |
IntPoint ScrollView::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& parentPoint) const |
|
866 |
{ |
|
867 |
IntPoint newPoint = parentPoint; |
|
868 |
// Scrollbars won't be transformed within us |
|
869 |
newPoint.move(-scrollbar->x(), -scrollbar->y()); |
|
870 |
return newPoint; |
|
871 |
} |
|
872 |
||
873 |
void ScrollView::setParentVisible(bool visible) |
|
874 |
{ |
|
875 |
if (isParentVisible() == visible) |
|
876 |
return; |
|
877 |
||
878 |
Widget::setParentVisible(visible); |
|
879 |
||
880 |
if (!isSelfVisible()) |
|
881 |
return; |
|
882 |
||
883 |
HashSet<RefPtr<Widget> >::iterator end = m_children.end(); |
|
884 |
for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it != end; ++it) |
|
885 |
(*it)->setParentVisible(visible); |
|
886 |
} |
|
887 |
||
888 |
void ScrollView::show() |
|
889 |
{ |
|
890 |
if (!isSelfVisible()) { |
|
891 |
setSelfVisible(true); |
|
892 |
if (isParentVisible()) { |
|
893 |
HashSet<RefPtr<Widget> >::iterator end = m_children.end(); |
|
894 |
for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it != end; ++it) |
|
895 |
(*it)->setParentVisible(true); |
|
896 |
} |
|
897 |
} |
|
898 |
||
899 |
Widget::show(); |
|
900 |
} |
|
901 |
||
902 |
void ScrollView::hide() |
|
903 |
{ |
|
904 |
if (isSelfVisible()) { |
|
905 |
if (isParentVisible()) { |
|
906 |
HashSet<RefPtr<Widget> >::iterator end = m_children.end(); |
|
907 |
for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it != end; ++it) |
|
908 |
(*it)->setParentVisible(false); |
|
909 |
} |
|
910 |
setSelfVisible(false); |
|
911 |
} |
|
912 |
||
913 |
Widget::hide(); |
|
914 |
} |
|
915 |
||
916 |
bool ScrollView::isOffscreen() const |
|
917 |
{ |
|
918 |
if (platformWidget()) |
|
919 |
return platformIsOffscreen(); |
|
920 |
||
921 |
if (!isVisible()) |
|
922 |
return true; |
|
923 |
||
924 |
// FIXME: Add a HostWindow::isOffscreen method here. Since only Mac implements this method |
|
925 |
// currently, we can add the method when the other platforms decide to implement this concept. |
|
926 |
return false; |
|
927 |
} |
|
928 |
||
929 |
||
930 |
void ScrollView::addPanScrollIcon(const IntPoint& iconPosition) |
|
931 |
{ |
|
932 |
if (!hostWindow()) |
|
933 |
return; |
|
934 |
m_drawPanScrollIcon = true; |
|
935 |
m_panScrollIconPoint = IntPoint(iconPosition.x() - panIconSizeLength / 2 , iconPosition.y() - panIconSizeLength / 2) ; |
|
936 |
hostWindow()->repaint(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength,panIconSizeLength)), true, true); |
|
937 |
} |
|
938 |
||
939 |
void ScrollView::removePanScrollIcon() |
|
940 |
{ |
|
941 |
if (!hostWindow()) |
|
942 |
return; |
|
943 |
m_drawPanScrollIcon = false; |
|
944 |
hostWindow()->repaint(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength, panIconSizeLength)), true, true); |
|
945 |
} |
|
946 |
||
947 |
#if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(QT) |
|
948 |
||
949 |
void ScrollView::platformInit() |
|
950 |
{ |
|
951 |
} |
|
952 |
||
953 |
void ScrollView::platformDestroy() |
|
954 |
{ |
|
955 |
} |
|
956 |
||
957 |
#endif |
|
958 |
||
959 |
#if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(MAC) |
|
960 |
||
961 |
void ScrollView::platformAddChild(Widget*) |
|
962 |
{ |
|
963 |
} |
|
964 |
||
965 |
void ScrollView::platformRemoveChild(Widget*) |
|
966 |
{ |
|
967 |
} |
|
968 |
||
969 |
#endif |
|
970 |
||
971 |
#if !PLATFORM(MAC) |
|
972 |
||
973 |
void ScrollView::platformSetScrollbarsSuppressed(bool repaintOnUnsuppress) |
|
974 |
{ |
|
975 |
} |
|
976 |
||
977 |
#endif |
|
978 |
||
979 |
#if !PLATFORM(MAC) && !PLATFORM(WX) |
|
980 |
||
981 |
void ScrollView::platformSetScrollbarModes() |
|
982 |
{ |
|
983 |
} |
|
984 |
||
985 |
void ScrollView::platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const |
|
986 |
{ |
|
987 |
horizontal = ScrollbarAuto; |
|
988 |
vertical = ScrollbarAuto; |
|
989 |
} |
|
990 |
||
991 |
void ScrollView::platformSetCanBlitOnScroll(bool) |
|
992 |
{ |
|
993 |
} |
|
994 |
||
995 |
bool ScrollView::platformCanBlitOnScroll() const |
|
996 |
{ |
|
997 |
return false; |
|
998 |
} |
|
999 |
||
1000 |
IntRect ScrollView::platformVisibleContentRect(bool) const |
|
1001 |
{ |
|
1002 |
return IntRect(); |
|
1003 |
} |
|
1004 |
||
1005 |
IntSize ScrollView::platformContentsSize() const |
|
1006 |
{ |
|
1007 |
return IntSize(); |
|
1008 |
} |
|
1009 |
||
1010 |
void ScrollView::platformSetContentsSize() |
|
1011 |
{ |
|
1012 |
} |
|
1013 |
||
1014 |
IntRect ScrollView::platformContentsToScreen(const IntRect& rect) const |
|
1015 |
{ |
|
1016 |
return rect; |
|
1017 |
} |
|
1018 |
||
1019 |
IntPoint ScrollView::platformScreenToContents(const IntPoint& point) const |
|
1020 |
{ |
|
1021 |
return point; |
|
1022 |
} |
|
1023 |
||
1024 |
void ScrollView::platformSetScrollPosition(const IntPoint&) |
|
1025 |
{ |
|
1026 |
} |
|
1027 |
||
1028 |
bool ScrollView::platformScroll(ScrollDirection, ScrollGranularity) |
|
1029 |
{ |
|
1030 |
return true; |
|
1031 |
} |
|
1032 |
||
1033 |
void ScrollView::platformRepaintContentRectangle(const IntRect&, bool now) |
|
1034 |
{ |
|
1035 |
} |
|
1036 |
||
1037 |
bool ScrollView::platformIsOffscreen() const |
|
1038 |
{ |
|
1039 |
return false; |
|
1040 |
} |
|
1041 |
||
1042 |
#endif |
|
1043 |
||
1044 |
} |
|
1045 |