| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 return scrollAnimator()->userScroll(orientation, granularity, step, delta); | 157 return scrollAnimator()->userScroll(orientation, granularity, step, delta); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) | 160 void ScrollableArea::setScrollPosition(const DoublePoint& position, ScrollType s
crollType, ScrollBehavior behavior) |
| 161 { | 161 { |
| 162 if (behavior == ScrollBehaviorAuto) | 162 if (behavior == ScrollBehaviorAuto) |
| 163 behavior = scrollBehaviorStyle(); | 163 behavior = scrollBehaviorStyle(); |
| 164 | 164 |
| 165 if (scrollType == CompositorScroll) | 165 if (scrollType == CompositorScroll) |
| 166 scrollPositionChanged(adjustScrollPositionWithinRange(position), Composi
torScroll); | 166 scrollPositionChanged(clampScrollPosition(position), CompositorScroll); |
| 167 else if (scrollType == ProgrammaticScroll) | 167 else if (scrollType == ProgrammaticScroll) |
| 168 programmaticScrollHelper(position, behavior); | 168 programmaticScrollHelper(position, behavior); |
| 169 else if (scrollType == UserScroll) | 169 else if (scrollType == UserScroll) |
| 170 userScrollHelper(position, behavior); | 170 userScrollHelper(position, behavior); |
| 171 else | 171 else |
| 172 ASSERT_NOT_REACHED(); | 172 ASSERT_NOT_REACHED(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void ScrollableArea::scrollBy(const DoubleSize& delta, ScrollType type, ScrollBe
havior behavior) | 175 void ScrollableArea::scrollBy(const DoubleSize& delta, ScrollType type, ScrollBe
havior behavior) |
| 176 { | 176 { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 ScrollResult ScrollableArea::handleWheel(const PlatformWheelEvent& wheelEvent) | 299 ScrollResult ScrollableArea::handleWheel(const PlatformWheelEvent& wheelEvent) |
| 300 { | 300 { |
| 301 // Wheel events which do not scroll are used to trigger zooming. | 301 // Wheel events which do not scroll are used to trigger zooming. |
| 302 if (!wheelEvent.canScroll()) | 302 if (!wheelEvent.canScroll()) |
| 303 return ScrollResult(); | 303 return ScrollResult(); |
| 304 | 304 |
| 305 cancelProgrammaticScrollAnimation(); | 305 cancelProgrammaticScrollAnimation(); |
| 306 return scrollAnimator()->handleWheelEvent(wheelEvent); | 306 return scrollAnimator()->handleWheelEvent(wheelEvent); |
| 307 } | 307 } |
| 308 | 308 |
| 309 IntPoint ScrollableArea::adjustScrollPositionWithinRange(const IntPoint& scrollP
oint) const | |
| 310 { | |
| 311 IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); | |
| 312 newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); | |
| 313 return newScrollPosition; | |
| 314 } | |
| 315 | |
| 316 DoublePoint ScrollableArea::adjustScrollPositionWithinRange(const DoublePoint& s
crollPoint) const | |
| 317 { | |
| 318 DoublePoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPositionDo
uble()); | |
| 319 newScrollPosition = newScrollPosition.expandedTo(minimumScrollPositionDouble
()); | |
| 320 return newScrollPosition; | |
| 321 } | |
| 322 | |
| 323 // NOTE: Only called from Internals for testing. | 309 // NOTE: Only called from Internals for testing. |
| 324 void ScrollableArea::setScrollOffsetFromInternals(const IntPoint& offset) | 310 void ScrollableArea::setScrollOffsetFromInternals(const IntPoint& offset) |
| 325 { | 311 { |
| 326 scrollPositionChanged(DoublePoint(offset), ProgrammaticScroll); | 312 scrollPositionChanged(DoublePoint(offset), ProgrammaticScroll); |
| 327 } | 313 } |
| 328 | 314 |
| 329 void ScrollableArea::willStartLiveResize() | 315 void ScrollableArea::willStartLiveResize() |
| 330 { | 316 { |
| 331 if (m_inLiveResize) | 317 if (m_inLiveResize) |
| 332 return; | 318 return; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; | 602 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; |
| 617 if (Scrollbar* horizontalBar = horizontalScrollbar()) | 603 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
| 618 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; | 604 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; |
| 619 | 605 |
| 620 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), | 606 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), |
| 621 std::max(0, size.height() - horizontalScrollbarHeight)); | 607 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 622 | 608 |
| 623 } | 609 } |
| 624 | 610 |
| 625 } // namespace blink | 611 } // namespace blink |
| OLD | NEW |