OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalS
crollbar : m_verticalScrollbar).get(); | 299 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalS
crollbar : m_verticalScrollbar).get(); |
300 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; | 300 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; |
301 } | 301 } |
302 | 302 |
303 void ScrollView::notifyPageThatContentAreaWillPaint() const | 303 void ScrollView::notifyPageThatContentAreaWillPaint() const |
304 { | 304 { |
305 } | 305 } |
306 | 306 |
307 void ScrollView::setScrollOffset(const IntPoint& offset) | 307 void ScrollView::setScrollOffset(const IntPoint& offset) |
308 { | 308 { |
309 int horizontalOffset = offset.x(); | 309 scrollTo(toIntSize(adjustScrollPositionWithinRange(offset))); |
310 int verticalOffset = offset.y(); | |
311 if (constrainsScrollingToContentEdge()) { | |
312 horizontalOffset = max(min(horizontalOffset, contentsWidth() - visibleWi
dth()), 0); | |
313 verticalOffset = max(min(verticalOffset, contentsHeight() - visibleHeigh
t()), 0); | |
314 } | |
315 | |
316 IntSize newOffset = m_scrollOffset; | |
317 newOffset.setWidth(horizontalOffset - scrollOrigin().x()); | |
318 newOffset.setHeight(verticalOffset - scrollOrigin().y()); | |
319 | |
320 scrollTo(newOffset); | |
321 } | 310 } |
322 | 311 |
323 void ScrollView::scrollTo(const IntSize& newOffset) | 312 void ScrollView::scrollTo(const IntSize& newOffset) |
324 { | 313 { |
325 IntSize scrollDelta = newOffset - m_scrollOffset; | 314 IntSize scrollDelta = newOffset - m_scrollOffset; |
326 if (scrollDelta == IntSize()) | 315 if (scrollDelta == IntSize()) |
327 return; | 316 return; |
328 m_scrollOffset = newOffset; | 317 m_scrollOffset = newOffset; |
329 | 318 |
330 if (scrollbarsSuppressed()) | 319 if (scrollbarsSuppressed()) |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 updateScrollCorner(); | 537 updateScrollCorner(); |
549 if (!m_horizontalScrollbar && !m_verticalScrollbar) | 538 if (!m_horizontalScrollbar && !m_verticalScrollbar) |
550 invalidateScrollCornerRect(oldScrollCornerRect); | 539 invalidateScrollCornerRect(oldScrollCornerRect); |
551 } | 540 } |
552 | 541 |
553 IntPoint adjustedScrollPosition = IntPoint(desiredOffset); | 542 IntPoint adjustedScrollPosition = IntPoint(desiredOffset); |
554 if (!isRubberBandInProgress()) | 543 if (!isRubberBandInProgress()) |
555 adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollP
osition); | 544 adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollP
osition); |
556 | 545 |
557 if (adjustedScrollPosition != scrollPosition() || scrollOriginChanged()) { | 546 if (adjustedScrollPosition != scrollPosition() || scrollOriginChanged()) { |
558 ScrollableArea::scrollToOffsetWithoutAnimation(adjustedScrollPosition +
IntSize(scrollOrigin().x(), scrollOrigin().y())); | 547 ScrollableArea::scrollToOffsetWithoutAnimation(adjustedScrollPosition); |
559 resetScrollOriginChanged(); | 548 resetScrollOriginChanged(); |
560 } | 549 } |
561 | 550 |
562 // Make sure the scrollbar offsets are up to date. | 551 // Make sure the scrollbar offsets are up to date. |
563 if (m_horizontalScrollbar) | 552 if (m_horizontalScrollbar) |
564 m_horizontalScrollbar->offsetDidChange(); | 553 m_horizontalScrollbar->offsetDidChange(); |
565 if (m_verticalScrollbar) | 554 if (m_verticalScrollbar) |
566 m_verticalScrollbar->offsetDidChange(); | 555 m_verticalScrollbar->offsetDidChange(); |
567 | 556 |
568 m_inUpdateScrollbars = false; | 557 m_inUpdateScrollbars = false; |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 { | 1260 { |
1272 } | 1261 } |
1273 | 1262 |
1274 bool ScrollView::platformIsOffscreen() const | 1263 bool ScrollView::platformIsOffscreen() const |
1275 { | 1264 { |
1276 return false; | 1265 return false; |
1277 } | 1266 } |
1278 | 1267 |
1279 | 1268 |
1280 } | 1269 } |
OLD | NEW |