| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 "sky/viewer/cc/scrollbar_impl.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "sky/engine/public/platform/WebScrollbar.h" | |
| 9 #include "sky/engine/public/platform/WebScrollbarThemeGeometry.h" | |
| 10 | |
| 11 using blink::WebScrollbar; | |
| 12 | |
| 13 namespace sky_viewer_cc { | |
| 14 | |
| 15 ScrollbarImpl::ScrollbarImpl( | |
| 16 scoped_ptr<WebScrollbar> scrollbar, | |
| 17 blink::WebScrollbarThemePainter painter, | |
| 18 scoped_ptr<blink::WebScrollbarThemeGeometry> geometry) | |
| 19 : scrollbar_(scrollbar.Pass()), | |
| 20 painter_(painter), | |
| 21 geometry_(geometry.Pass()) { | |
| 22 } | |
| 23 | |
| 24 ScrollbarImpl::~ScrollbarImpl() { | |
| 25 } | |
| 26 | |
| 27 cc::ScrollbarOrientation ScrollbarImpl::Orientation() const { | |
| 28 if (scrollbar_->orientation() == WebScrollbar::Horizontal) | |
| 29 return cc::HORIZONTAL; | |
| 30 return cc::VERTICAL; | |
| 31 } | |
| 32 | |
| 33 bool ScrollbarImpl::IsLeftSideVerticalScrollbar() const { | |
| 34 return scrollbar_->isLeftSideVerticalScrollbar(); | |
| 35 } | |
| 36 | |
| 37 bool ScrollbarImpl::HasThumb() const { | |
| 38 return true; | |
| 39 }; | |
| 40 | |
| 41 bool ScrollbarImpl::IsOverlay() const { | |
| 42 return scrollbar_->isOverlay(); | |
| 43 } | |
| 44 | |
| 45 gfx::Point ScrollbarImpl::Location() const { | |
| 46 return scrollbar_->location(); | |
| 47 } | |
| 48 | |
| 49 int ScrollbarImpl::ThumbThickness() const { | |
| 50 gfx::Rect thumb_rect = geometry_->thumbRect(); | |
| 51 if (scrollbar_->orientation() == WebScrollbar::Horizontal) | |
| 52 return thumb_rect.height(); | |
| 53 return thumb_rect.width(); | |
| 54 } | |
| 55 | |
| 56 int ScrollbarImpl::ThumbLength() const { | |
| 57 gfx::Rect thumb_rect = geometry_->thumbRect(); | |
| 58 if (scrollbar_->orientation() == WebScrollbar::Horizontal) | |
| 59 return thumb_rect.width(); | |
| 60 return thumb_rect.height(); | |
| 61 } | |
| 62 | |
| 63 gfx::Rect ScrollbarImpl::TrackRect() const { | |
| 64 return geometry_->trackRect(); | |
| 65 } | |
| 66 | |
| 67 void ScrollbarImpl::PaintPart(SkCanvas* canvas, | |
| 68 cc::ScrollbarPart part, | |
| 69 const gfx::Rect& content_rect) { | |
| 70 if (part == cc::THUMB) { | |
| 71 painter_.paintThumb(canvas, content_rect); | |
| 72 return; | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 } // namespace sky_viewer_cc | |
| OLD | NEW |