OLD | NEW |
(Empty) | |
| 1 #include "cc/pinch_zoom_scrollbar.h" |
| 2 |
| 3 #include "cc/layer.h" |
| 4 #include "cc/layer_tree_host.h" |
| 5 |
| 6 namespace cc { |
| 7 |
| 8 PinchZoomScrollbar::PinchZoomScrollbar( |
| 9 WebKit::WebScrollbar::Orientation orientation, LayerTreeHost* owner) |
| 10 : orientation_(orientation), |
| 11 owner_(owner) { |
| 12 DCHECK(owner_); |
| 13 } |
| 14 |
| 15 |
| 16 bool PinchZoomScrollbar::isOverlay() const { return true; } |
| 17 |
| 18 int PinchZoomScrollbar::value() const { |
| 19 Layer* rootScrollLayer = owner_->rootScrollLayer(); |
| 20 if (!rootScrollLayer) |
| 21 return 0; |
| 22 |
| 23 if (orientation_ == WebKit::WebScrollbar::Horizontal) |
| 24 return rootScrollLayer->scrollOffset().x(); |
| 25 else |
| 26 return rootScrollLayer->scrollOffset().y(); |
| 27 } |
| 28 |
| 29 WebKit::WebPoint PinchZoomScrollbar::location() const { |
| 30 return WebKit::WebPoint(); |
| 31 } |
| 32 |
| 33 WebKit::WebSize PinchZoomScrollbar::size() const { |
| 34 gfx::Size viewportSize = owner_->layoutViewportSize(); |
| 35 gfx::Size size; |
| 36 if (orientation_ == WebKit::WebScrollbar::Horizontal) |
| 37 size = gfx::Size(viewportSize.width() - kTrackWidth, kTrackWidth); |
| 38 else |
| 39 size = gfx::Size(kTrackWidth, viewportSize.height() - kTrackWidth); |
| 40 return WebKit::WebSize(size); |
| 41 } |
| 42 |
| 43 bool PinchZoomScrollbar::enabled() const { |
| 44 return true; |
| 45 } |
| 46 |
| 47 int PinchZoomScrollbar::maximum() const { |
| 48 gfx::Size size = owner_->layoutViewportSize(); |
| 49 Layer* rootScrollLayer = owner_->rootScrollLayer(); |
| 50 if (!rootScrollLayer) |
| 51 return 0; |
| 52 |
| 53 if (orientation_ == WebKit::WebScrollbar::Horizontal) |
| 54 return rootScrollLayer->contentBounds().width() - size.width(); |
| 55 else |
| 56 return rootScrollLayer->contentBounds().height() - size.height(); |
| 57 } |
| 58 |
| 59 int PinchZoomScrollbar::totalSize() const { |
| 60 Layer* rootScrollLayer = owner_->rootScrollLayer(); |
| 61 gfx::Size size; |
| 62 if (rootScrollLayer) |
| 63 size = rootScrollLayer->contentBounds(); |
| 64 else |
| 65 size = owner_->layoutViewportSize(); |
| 66 |
| 67 if (orientation_ == WebKit::WebScrollbar::Horizontal) |
| 68 return size.width(); |
| 69 else |
| 70 return size.height(); |
| 71 } |
| 72 |
| 73 bool PinchZoomScrollbar::isScrollViewScrollbar() const { |
| 74 return false; |
| 75 } |
| 76 |
| 77 bool PinchZoomScrollbar::isScrollableAreaActive() const { |
| 78 return true; |
| 79 } |
| 80 |
| 81 WebKit::WebScrollbar::ScrollbarControlSize PinchZoomScrollbar::controlSize() con
st { |
| 82 return WebKit::WebScrollbar::SmallScrollbar; |
| 83 } |
| 84 |
| 85 WebKit::WebScrollbar::ScrollbarPart PinchZoomScrollbar::pressedPart() const { |
| 86 return WebKit::WebScrollbar::NoPart; |
| 87 } |
| 88 |
| 89 WebKit::WebScrollbar::ScrollbarPart PinchZoomScrollbar::hoveredPart() const { |
| 90 return WebKit::WebScrollbar::NoPart; |
| 91 } |
| 92 |
| 93 WebKit::WebScrollbar::ScrollbarOverlayStyle PinchZoomScrollbar::scrollbarOverlay
Style() const { |
| 94 return WebKit::WebScrollbar::ScrollbarOverlayStyleDefault; |
| 95 } |
| 96 bool PinchZoomScrollbar::isCustomScrollbar() const { |
| 97 return false; |
| 98 } |
| 99 |
| 100 WebKit::WebScrollbar::Orientation PinchZoomScrollbar::orientation() const { |
| 101 return orientation_; |
| 102 } |
| 103 |
| 104 } // namespace cc |
OLD | NEW |