| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 updateScrollbars(scrollOffset()); | 266 updateScrollbars(scrollOffset()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 IntPoint ScrollView::maximumScrollPosition() const | 269 IntPoint ScrollView::maximumScrollPosition() const |
| 270 { | 270 { |
| 271 IntSize maximumOffset = contentsSize() - visibleContentRect().size(); | 271 IntSize maximumOffset = contentsSize() - visibleContentRect().size(); |
| 272 maximumOffset.clampNegativeToZero(); | 272 maximumOffset.clampNegativeToZero(); |
| 273 return IntPoint(maximumOffset.width(), maximumOffset.height()); | 273 return IntPoint(maximumOffset.width(), maximumOffset.height()); |
| 274 } | 274 } |
| 275 | 275 |
| 276 int ScrollView::scrollSize(ScrollbarOrientation orientation) const |
| 277 { |
| 278 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalS
crollbar : m_verticalScrollbar).get(); |
| 279 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; |
| 280 } |
| 281 |
| 282 void ScrollView::setScrollOffsetFromAnimation(const IntPoint& offset) |
| 283 { |
| 284 if (m_horizontalScrollbar) |
| 285 m_horizontalScrollbar->setValue(offset.x(), Scrollbar::FromScrollAnimato
r); |
| 286 if (m_verticalScrollbar) |
| 287 m_verticalScrollbar->setValue(offset.y(), Scrollbar::FromScrollAnimator)
; |
| 288 } |
| 289 |
| 276 void ScrollView::valueChanged(Scrollbar* scrollbar) | 290 void ScrollView::valueChanged(Scrollbar* scrollbar) |
| 277 { | 291 { |
| 278 // Figure out if we really moved. | 292 // Figure out if we really moved. |
| 279 IntSize newOffset = m_scrollOffset; | 293 IntSize newOffset = m_scrollOffset; |
| 280 if (scrollbar) { | 294 if (scrollbar) { |
| 281 if (scrollbar->orientation() == HorizontalScrollbar) | 295 if (scrollbar->orientation() == HorizontalScrollbar) |
| 282 newOffset.setWidth(scrollbar->value()); | 296 newOffset.setWidth(scrollbar->value()); |
| 283 else if (scrollbar->orientation() == VerticalScrollbar) | 297 else if (scrollbar->orientation() == VerticalScrollbar) |
| 284 newOffset.setHeight(scrollbar->value()); | 298 newOffset.setHeight(scrollbar->value()); |
| 285 } | 299 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 width() - (m_verticalScrollbar ? m_verticalSc
rollbar->width() : 0), | 448 width() - (m_verticalScrollbar ? m_verticalSc
rollbar->width() : 0), |
| 435 m_horizontalScrollbar->height()); | 449 m_horizontalScrollbar->height()); |
| 436 m_horizontalScrollbar->setFrameRect(hBarRect); | 450 m_horizontalScrollbar->setFrameRect(hBarRect); |
| 437 if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRe
ct()) | 451 if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRe
ct()) |
| 438 m_horizontalScrollbar->invalidate(); | 452 m_horizontalScrollbar->invalidate(); |
| 439 | 453 |
| 440 if (m_scrollbarsSuppressed) | 454 if (m_scrollbarsSuppressed) |
| 441 m_horizontalScrollbar->setSuppressInvalidation(true); | 455 m_horizontalScrollbar->setSuppressInvalidation(true); |
| 442 m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep
); | 456 m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep
); |
| 443 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); | 457 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); |
| 444 m_horizontalScrollbar->setValue(scroll.width()); | 458 m_horizontalScrollbar->setValue(scroll.width(), Scrollbar::NotFromScroll
Animator); |
| 445 if (m_scrollbarsSuppressed) | 459 if (m_scrollbarsSuppressed) |
| 446 m_horizontalScrollbar->setSuppressInvalidation(false); | 460 m_horizontalScrollbar->setSuppressInvalidation(false); |
| 447 } | 461 } |
| 448 | 462 |
| 449 if (m_verticalScrollbar) { | 463 if (m_verticalScrollbar) { |
| 450 int clientHeight = visibleHeight(); | 464 int clientHeight = visibleHeight(); |
| 451 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); | 465 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); |
| 452 int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepW
henPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); | 466 int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepW
henPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); |
| 453 IntRect oldRect(m_verticalScrollbar->frameRect()); | 467 IntRect oldRect(m_verticalScrollbar->frameRect()); |
| 454 IntRect vBarRect = IntRect(width() - m_verticalScrollbar->width(), | 468 IntRect vBarRect = IntRect(width() - m_verticalScrollbar->width(), |
| 455 0, | 469 0, |
| 456 m_verticalScrollbar->width(), | 470 m_verticalScrollbar->width(), |
| 457 height() - (m_horizontalScrollbar ? m_horizon
talScrollbar->height() : 0)); | 471 height() - (m_horizontalScrollbar ? m_horizon
talScrollbar->height() : 0)); |
| 458 m_verticalScrollbar->setFrameRect(vBarRect); | 472 m_verticalScrollbar->setFrameRect(vBarRect); |
| 459 if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect
()) | 473 if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect
()) |
| 460 m_verticalScrollbar->invalidate(); | 474 m_verticalScrollbar->invalidate(); |
| 461 | 475 |
| 462 if (m_scrollbarsSuppressed) | 476 if (m_scrollbarsSuppressed) |
| 463 m_verticalScrollbar->setSuppressInvalidation(true); | 477 m_verticalScrollbar->setSuppressInvalidation(true); |
| 464 m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); | 478 m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); |
| 465 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); | 479 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); |
| 466 m_verticalScrollbar->setValue(scroll.height()); | 480 m_verticalScrollbar->setValue(scroll.height(), Scrollbar::NotFromScrollA
nimator); |
| 467 if (m_scrollbarsSuppressed) | 481 if (m_scrollbarsSuppressed) |
| 468 m_verticalScrollbar->setSuppressInvalidation(false); | 482 m_verticalScrollbar->setSuppressInvalidation(false); |
| 469 } | 483 } |
| 470 | 484 |
| 471 if (hasHorizontalScrollbar != (m_horizontalScrollbar != 0) || hasVerticalScr
ollbar != (m_verticalScrollbar != 0)) { | 485 if (hasHorizontalScrollbar != (m_horizontalScrollbar != 0) || hasVerticalScr
ollbar != (m_verticalScrollbar != 0)) { |
| 472 frameRectsChanged(); | 486 frameRectsChanged(); |
| 473 updateScrollCorner(); | 487 updateScrollCorner(); |
| 474 } | 488 } |
| 475 | 489 |
| 476 // See if our offset has changed in a situation where we might not have scro
llbars. | 490 // See if our offset has changed in a situation where we might not have scro
llbars. |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 e.accept(); | 680 e.accept(); |
| 667 float deltaX = e.deltaX(); | 681 float deltaX = e.deltaX(); |
| 668 float deltaY = e.deltaY(); | 682 float deltaY = e.deltaY(); |
| 669 if (e.granularity() == ScrollByPageWheelEvent) { | 683 if (e.granularity() == ScrollByPageWheelEvent) { |
| 670 ASSERT(deltaX == 0); | 684 ASSERT(deltaX == 0); |
| 671 bool negative = deltaY < 0; | 685 bool negative = deltaY < 0; |
| 672 deltaY = max(max(static_cast<float>(visibleHeight()) * Scrollbar::mi
nFractionToStepWhenPaging(), static_cast<float>(visibleHeight() - Scrollbar::max
OverlapBetweenPages())), 1.0f); | 686 deltaY = max(max(static_cast<float>(visibleHeight()) * Scrollbar::mi
nFractionToStepWhenPaging(), static_cast<float>(visibleHeight() - Scrollbar::max
OverlapBetweenPages())), 1.0f); |
| 673 if (negative) | 687 if (negative) |
| 674 deltaY = -deltaY; | 688 deltaY = -deltaY; |
| 675 } | 689 } |
| 676 scrollBy(IntSize(-deltaX, -deltaY)); | 690 |
| 691 // Should we fall back on scrollBy() if there is no scrollbar for a non-
zero delta? |
| 692 if (deltaY && m_verticalScrollbar) |
| 693 m_verticalScrollbar->scroll(ScrollUp, ScrollByPixel, deltaY); |
| 694 if (deltaX && m_horizontalScrollbar) |
| 695 m_horizontalScrollbar->scroll(ScrollLeft, ScrollByPixel, deltaX); |
| 677 } | 696 } |
| 678 } | 697 } |
| 679 | 698 |
| 680 void ScrollView::setFrameRect(const IntRect& newRect) | 699 void ScrollView::setFrameRect(const IntRect& newRect) |
| 681 { | 700 { |
| 682 IntRect oldRect = frameRect(); | 701 IntRect oldRect = frameRect(); |
| 683 | 702 |
| 684 if (newRect == oldRect) | 703 if (newRect == oldRect) |
| 685 return; | 704 return; |
| 686 | 705 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 | 1062 |
| 1044 bool ScrollView::platformIsOffscreen() const | 1063 bool ScrollView::platformIsOffscreen() const |
| 1045 { | 1064 { |
| 1046 return false; | 1065 return false; |
| 1047 } | 1066 } |
| 1048 | 1067 |
| 1049 #endif | 1068 #endif |
| 1050 | 1069 |
| 1051 } | 1070 } |
| 1052 | 1071 |
| OLD | NEW |