Chromium Code Reviews| 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 FloatRect tmpRectInViewport = host->windowToViewport(FloatRect(1, 0, 0, 0)); | |
| 68 return kPixelsPerLineStep * tmpRectInViewport.x(); | |
| 66 } | 69 } |
| 67 | 70 |
| 68 float ScrollableArea::minFractionToStepWhenPaging() | 71 float ScrollableArea::minFractionToStepWhenPaging() |
| 69 { | 72 { |
| 70 return kMinFractionToStepWhenPaging; | 73 return kMinFractionToStepWhenPaging; |
| 71 } | 74 } |
| 72 | 75 |
| 73 int ScrollableArea::maxOverlapBetweenPages() | 76 int ScrollableArea::maxOverlapBetweenPages() |
| 74 { | 77 { |
| 75 static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetwee nPages(); | 78 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()); | 562 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); |
| 560 } | 563 } |
| 561 | 564 |
| 562 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio n) const | 565 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio n) const |
| 563 { | 566 { |
| 564 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min imumScrollPositionDouble()); | 567 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min imumScrollPositionDouble()); |
| 565 } | 568 } |
| 566 | 569 |
| 567 int ScrollableArea::lineStep(ScrollbarOrientation) const | 570 int ScrollableArea::lineStep(ScrollbarOrientation) const |
| 568 { | 571 { |
| 569 return pixelsPerLineStep(); | 572 return pixelsPerLineStep(hostWindow()); |
| 570 } | 573 } |
| 571 | 574 |
| 572 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const | 575 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const |
| 573 { | 576 { |
| 574 IntRect visibleRect = visibleContentRect(IncludeScrollbars); | 577 IntRect visibleRect = visibleContentRect(IncludeScrollbars); |
| 575 int length = (orientation == HorizontalScrollbar) ? visibleRect.width() : vi sibleRect.height(); | 578 int length = (orientation == HorizontalScrollbar) ? visibleRect.width() : vi sibleRect.height(); |
| 576 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ; | 579 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ; |
| 577 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); | 580 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); |
| 578 | 581 |
| 579 return std::max(pageStep, 1); | 582 return std::max(pageStep, 1); |
| 580 } | 583 } |
| 581 | 584 |
| 582 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const | 585 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const |
| 583 { | 586 { |
| 584 return scrollSize(orientation); | 587 return scrollSize(orientation); |
| 585 } | 588 } |
| 586 | 589 |
| 587 float ScrollableArea::pixelStep(ScrollbarOrientation) const | 590 float ScrollableArea::pixelStep(ScrollbarOrientation) const |
| 588 { | 591 { |
| 589 return 1; | 592 return 1; |
|
oshima
2016/02/09 02:05:02
Looks like this is DIP, but I'm not sure convertin
skobes
2016/02/09 18:36:06
As far as I know ScrollableArea only deals in DIPs
oshima
2016/02/09 23:15:07
In use-zoom-for-dsf mode, the viewport pixel becom
| |
| 590 } | 593 } |
| 591 | 594 |
| 592 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const | 595 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const |
| 593 { | 596 { |
| 594 int verticalScrollbarWidth = 0; | 597 int verticalScrollbarWidth = 0; |
| 595 int horizontalScrollbarHeight = 0; | 598 int horizontalScrollbarHeight = 0; |
| 596 | 599 |
| 597 if (Scrollbar* verticalBar = verticalScrollbar()) | 600 if (Scrollbar* verticalBar = verticalScrollbar()) |
| 598 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0; | 601 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0; |
| 599 if (Scrollbar* horizontalBar = horizontalScrollbar()) | 602 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
| 600 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0; | 603 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0; |
| 601 | 604 |
| 602 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), | 605 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), |
| 603 std::max(0, size.height() - horizontalScrollbarHeight)); | 606 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 604 } | 607 } |
| 605 | 608 |
| 606 DEFINE_TRACE(ScrollableArea) | 609 DEFINE_TRACE(ScrollableArea) |
| 607 { | 610 { |
| 608 visitor->trace(m_scrollAnimator); | 611 visitor->trace(m_scrollAnimator); |
| 609 visitor->trace(m_programmaticScrollAnimator); | 612 visitor->trace(m_programmaticScrollAnimator); |
| 610 } | 613 } |
| 611 | 614 |
| 612 } // namespace blink | 615 } // namespace blink |
| OLD | NEW |