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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #if ENABLE(ASSERT) | 52 #if ENABLE(ASSERT) |
| 53 VerifyEagerFinalization verifyEager; | 53 VerifyEagerFinalization verifyEager; |
| 54 #endif | 54 #endif |
| 55 Member<void*> pointer[2]; | 55 Member<void*> pointer[2]; |
| 56 unsigned bitfields : 16; | 56 unsigned bitfields : 16; |
| 57 IntPoint origin; | 57 IntPoint origin; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), "Scrol lableArea should stay small"); | 60 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), "Scrol lableArea should stay small"); |
| 61 | 61 |
| 62 int ScrollableArea::pixelsPerLineStep(HostWindow* host) | 62 int ScrollableArea::pixelsPerLineStep(HostWindow* host, Widget* widget) |
| 63 { | 63 { |
| 64 if (!host) | 64 if (!host) |
| 65 return kPixelsPerLineStep; | 65 return kPixelsPerLineStep; |
| 66 return host->windowToViewportScalar(kPixelsPerLineStep); | 66 return host->windowToViewportScalar(kPixelsPerLineStep, widget); |
| 67 } | 67 } |
| 68 | 68 |
| 69 float ScrollableArea::minFractionToStepWhenPaging() | 69 float ScrollableArea::minFractionToStepWhenPaging() |
| 70 { | 70 { |
| 71 return kMinFractionToStepWhenPaging; | 71 return kMinFractionToStepWhenPaging; |
| 72 } | 72 } |
| 73 | 73 |
| 74 int ScrollableArea::maxOverlapBetweenPages() | 74 int ScrollableArea::maxOverlapBetweenPages() |
| 75 { | 75 { |
| 76 static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetwee nPages(); | 76 static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetwee nPages(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 GraphicsLayer* ScrollableArea::layerForContainer() const | 127 GraphicsLayer* ScrollableArea::layerForContainer() const |
| 128 { | 128 { |
| 129 return layerForScrolling() ? layerForScrolling()->parent() : 0; | 129 return layerForScrolling() ? layerForScrolling()->parent() : 0; |
| 130 } | 130 } |
| 131 | 131 |
| 132 ScrollbarOrientation ScrollableArea::scrollbarOrientationFromDirection(ScrollDir ectionPhysical direction) const | 132 ScrollbarOrientation ScrollableArea::scrollbarOrientationFromDirection(ScrollDir ectionPhysical direction) const |
| 133 { | 133 { |
| 134 return (direction == ScrollUp || direction == ScrollDown) ? VerticalScrollb ar : HorizontalScrollbar; | 134 return (direction == ScrollUp || direction == ScrollDown) ? VerticalScrollb ar : HorizontalScrollbar; |
| 135 } | 135 } |
| 136 | 136 |
| 137 float ScrollableArea::scrollStep(ScrollGranularity granularity, ScrollbarOrienta tion orientation) const | 137 float ScrollableArea::scrollStep(ScrollGranularity granularity, ScrollbarOrienta tion orientation) |
|
dcheng
2016/09/08 05:25:47
Argh const-correctness.
Let's just mark getWidget
lfg
2016/09/08 21:40:43
I tried that before, but FrameView::getWidget retu
| |
| 138 { | 138 { |
| 139 switch (granularity) { | 139 switch (granularity) { |
| 140 case ScrollByLine: | 140 case ScrollByLine: |
| 141 return lineStep(orientation); | 141 return lineStep(orientation); |
| 142 case ScrollByPage: | 142 case ScrollByPage: |
| 143 return pageStep(orientation); | 143 return pageStep(orientation); |
| 144 case ScrollByDocument: | 144 case ScrollByDocument: |
| 145 return documentStep(orientation); | 145 return documentStep(orientation); |
| 146 case ScrollByPixel: | 146 case ScrollByPixel: |
| 147 case ScrollByPrecisePixel: | 147 case ScrollByPrecisePixel: |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 IntPoint ScrollableArea::clampScrollPosition(const IntPoint& scrollPosition) con st | 560 IntPoint ScrollableArea::clampScrollPosition(const IntPoint& scrollPosition) con st |
| 561 { | 561 { |
| 562 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); | 562 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); |
| 563 } | 563 } |
| 564 | 564 |
| 565 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio n) const | 565 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio n) const |
| 566 { | 566 { |
| 567 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min imumScrollPositionDouble()); | 567 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min imumScrollPositionDouble()); |
| 568 } | 568 } |
| 569 | 569 |
| 570 int ScrollableArea::lineStep(ScrollbarOrientation) const | 570 int ScrollableArea::lineStep(ScrollbarOrientation) |
| 571 { | 571 { |
| 572 return pixelsPerLineStep(getHostWindow()); | 572 return pixelsPerLineStep(getHostWindow(), getWidget()); |
| 573 } | 573 } |
| 574 | 574 |
| 575 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const | 575 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const |
| 576 { | 576 { |
| 577 IntRect visibleRect = visibleContentRect(IncludeScrollbars); | 577 IntRect visibleRect = visibleContentRect(IncludeScrollbars); |
| 578 int length = (orientation == HorizontalScrollbar) ? visibleRect.width() : vi sibleRect.height(); | 578 int length = (orientation == HorizontalScrollbar) ? visibleRect.width() : vi sibleRect.height(); |
| 579 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ; | 579 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ; |
| 580 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); | 580 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); |
| 581 | 581 |
| 582 return std::max(pageStep, 1); | 582 return std::max(pageStep, 1); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 612 std::max(0, size.height() - horizontalScrollbarHeight())); | 612 std::max(0, size.height() - horizontalScrollbarHeight())); |
| 613 } | 613 } |
| 614 | 614 |
| 615 DEFINE_TRACE(ScrollableArea) | 615 DEFINE_TRACE(ScrollableArea) |
| 616 { | 616 { |
| 617 visitor->trace(m_scrollAnimator); | 617 visitor->trace(m_scrollAnimator); |
| 618 visitor->trace(m_programmaticScrollAnimator); | 618 visitor->trace(m_programmaticScrollAnimator); |
| 619 } | 619 } |
| 620 | 620 |
| 621 } // namespace blink | 621 } // namespace blink |
| OLD | NEW |