| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #if ENABLE(ASSERT) && ENABLE(OILPAN) | 53 #if ENABLE(ASSERT) && ENABLE(OILPAN) |
| 54 VerifyEagerFinalization verifyEager; | 54 VerifyEagerFinalization verifyEager; |
| 55 #endif | 55 #endif |
| 56 OwnPtrWillBeMember<void*> pointer[2]; | 56 OwnPtrWillBeMember<void*> pointer[2]; |
| 57 unsigned bitfields : 16; | 57 unsigned bitfields : 16; |
| 58 IntPoint origin; | 58 IntPoint origin; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), "Scrol
lableArea should stay small"); | 61 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), "Scrol
lableArea should stay small"); |
| 62 | 62 |
| 63 int ScrollableArea::pixelsPerLineStep() | 63 int ScrollableArea::pixelsPerLineStep(HostWindow* host) |
| 64 { | 64 { |
| 65 return kPixelsPerLineStep; | 65 if (!host) |
| 66 return kPixelsPerLineStep; |
| 67 return host->windowToViewportScalar(kPixelsPerLineStep); |
| 66 } | 68 } |
| 67 | 69 |
| 68 float ScrollableArea::minFractionToStepWhenPaging() | 70 float ScrollableArea::minFractionToStepWhenPaging() |
| 69 { | 71 { |
| 70 return kMinFractionToStepWhenPaging; | 72 return kMinFractionToStepWhenPaging; |
| 71 } | 73 } |
| 72 | 74 |
| 73 int ScrollableArea::maxOverlapBetweenPages() | 75 int ScrollableArea::maxOverlapBetweenPages() |
| 74 { | 76 { |
| 75 static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetwee
nPages(); | 77 static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetwee
nPages(); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc
rollPosition()); | 561 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc
rollPosition()); |
| 560 } | 562 } |
| 561 | 563 |
| 562 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio
n) const | 564 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio
n) const |
| 563 { | 565 { |
| 564 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min
imumScrollPositionDouble()); | 566 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min
imumScrollPositionDouble()); |
| 565 } | 567 } |
| 566 | 568 |
| 567 int ScrollableArea::lineStep(ScrollbarOrientation) const | 569 int ScrollableArea::lineStep(ScrollbarOrientation) const |
| 568 { | 570 { |
| 569 return pixelsPerLineStep(); | 571 return pixelsPerLineStep(hostWindow()); |
| 570 } | 572 } |
| 571 | 573 |
| 572 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const | 574 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const |
| 573 { | 575 { |
| 574 IntRect visibleRect = visibleContentRect(IncludeScrollbars); | 576 IntRect visibleRect = visibleContentRect(IncludeScrollbars); |
| 575 int length = (orientation == HorizontalScrollbar) ? visibleRect.width() : vi
sibleRect.height(); | 577 int length = (orientation == HorizontalScrollbar) ? visibleRect.width() : vi
sibleRect.height(); |
| 576 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging()
; | 578 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging()
; |
| 577 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); | 579 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); |
| 578 | 580 |
| 579 return std::max(pageStep, 1); | 581 return std::max(pageStep, 1); |
| 580 } | 582 } |
| 581 | 583 |
| 582 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const | 584 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const |
| 583 { | 585 { |
| 584 return scrollSize(orientation); | 586 return scrollSize(orientation); |
| 585 } | 587 } |
| 586 | 588 |
| 587 float ScrollableArea::pixelStep(ScrollbarOrientation) const | 589 float ScrollableArea::pixelStep(ScrollbarOrientation) const |
| 588 { | 590 { |
| 591 if (HostWindow* window = hostWindow()) |
| 592 return window->windowToViewportScalar(1); |
| 589 return 1; | 593 return 1; |
| 590 } | 594 } |
| 591 | 595 |
| 592 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const | 596 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const |
| 593 { | 597 { |
| 594 int verticalScrollbarWidth = 0; | 598 int verticalScrollbarWidth = 0; |
| 595 int horizontalScrollbarHeight = 0; | 599 int horizontalScrollbarHeight = 0; |
| 596 | 600 |
| 597 if (Scrollbar* verticalBar = verticalScrollbar()) | 601 if (Scrollbar* verticalBar = verticalScrollbar()) |
| 598 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; | 602 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; |
| 599 if (Scrollbar* horizontalBar = horizontalScrollbar()) | 603 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
| 600 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; | 604 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; |
| 601 | 605 |
| 602 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), | 606 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), |
| 603 std::max(0, size.height() - horizontalScrollbarHeight)); | 607 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 604 } | 608 } |
| 605 | 609 |
| 606 DEFINE_TRACE(ScrollableArea) | 610 DEFINE_TRACE(ScrollableArea) |
| 607 { | 611 { |
| 608 visitor->trace(m_scrollAnimator); | 612 visitor->trace(m_scrollAnimator); |
| 609 visitor->trace(m_programmaticScrollAnimator); | 613 visitor->trace(m_programmaticScrollAnimator); |
| 610 } | 614 } |
| 611 | 615 |
| 612 } // namespace blink | 616 } // namespace blink |
| OLD | NEW |