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