| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/renderer/compositor_bindings/scrollbar_impl.h" | 5 #include "content/renderer/compositor_bindings/scrollbar_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/WebKit/public/platform/WebScrollbar.h" | 8 #include "third_party/WebKit/public/platform/WebScrollbar.h" |
| 9 #include "third_party/WebKit/public/platform/WebScrollbarThemeGeometry.h" | 9 #include "third_party/WebKit/public/platform/WebScrollbarThemeGeometry.h" |
| 10 | 10 |
| 11 using blink::WebScrollbar; | 11 using blink::WebScrollbar; |
| 12 | 12 |
| 13 namespace webkit { | 13 namespace content { |
| 14 | 14 |
| 15 ScrollbarImpl::ScrollbarImpl( | 15 ScrollbarImpl::ScrollbarImpl( |
| 16 scoped_ptr<WebScrollbar> scrollbar, | 16 scoped_ptr<WebScrollbar> scrollbar, |
| 17 blink::WebScrollbarThemePainter painter, | 17 blink::WebScrollbarThemePainter painter, |
| 18 scoped_ptr<blink::WebScrollbarThemeGeometry> geometry) | 18 scoped_ptr<blink::WebScrollbarThemeGeometry> geometry) |
| 19 : scrollbar_(scrollbar.Pass()), | 19 : scrollbar_(scrollbar.Pass()), |
| 20 painter_(painter), | 20 painter_(painter), |
| 21 geometry_(geometry.Pass()) {} | 21 geometry_(geometry.Pass()) { |
| 22 } |
| 22 | 23 |
| 23 ScrollbarImpl::~ScrollbarImpl() {} | 24 ScrollbarImpl::~ScrollbarImpl() { |
| 25 } |
| 24 | 26 |
| 25 cc::ScrollbarOrientation ScrollbarImpl::Orientation() const { | 27 cc::ScrollbarOrientation ScrollbarImpl::Orientation() const { |
| 26 if (scrollbar_->orientation() == WebScrollbar::Horizontal) | 28 if (scrollbar_->orientation() == WebScrollbar::Horizontal) |
| 27 return cc::HORIZONTAL; | 29 return cc::HORIZONTAL; |
| 28 return cc::VERTICAL; | 30 return cc::VERTICAL; |
| 29 } | 31 } |
| 30 | 32 |
| 31 bool ScrollbarImpl::IsLeftSideVerticalScrollbar() const { | 33 bool ScrollbarImpl::IsLeftSideVerticalScrollbar() const { |
| 32 return scrollbar_->isLeftSideVerticalScrollbar(); | 34 return scrollbar_->isLeftSideVerticalScrollbar(); |
| 33 } | 35 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 55 gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get()); | 57 gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get()); |
| 56 if (scrollbar_->orientation() == WebScrollbar::Horizontal) | 58 if (scrollbar_->orientation() == WebScrollbar::Horizontal) |
| 57 return thumb_rect.width(); | 59 return thumb_rect.width(); |
| 58 return thumb_rect.height(); | 60 return thumb_rect.height(); |
| 59 } | 61 } |
| 60 | 62 |
| 61 gfx::Rect ScrollbarImpl::TrackRect() const { | 63 gfx::Rect ScrollbarImpl::TrackRect() const { |
| 62 return geometry_->trackRect(scrollbar_.get()); | 64 return geometry_->trackRect(scrollbar_.get()); |
| 63 } | 65 } |
| 64 | 66 |
| 65 void ScrollbarImpl::PaintPart( | 67 void ScrollbarImpl::PaintPart(SkCanvas* canvas, |
| 66 SkCanvas* canvas, cc::ScrollbarPart part, | 68 cc::ScrollbarPart part, |
| 67 const gfx::Rect& content_rect) { | 69 const gfx::Rect& content_rect) { |
| 68 if (part == cc::THUMB) { | 70 if (part == cc::THUMB) { |
| 69 painter_.paintThumb(canvas, content_rect); | 71 painter_.paintThumb(canvas, content_rect); |
| 70 return; | 72 return; |
| 71 } | 73 } |
| 72 | 74 |
| 73 // The following is a simplification of ScrollbarThemeComposite::paint. | 75 // The following is a simplification of ScrollbarThemeComposite::paint. |
| 74 painter_.paintScrollbarBackground(canvas, content_rect); | 76 painter_.paintScrollbarBackground(canvas, content_rect); |
| 75 | 77 |
| 76 if (geometry_->hasButtons(scrollbar_.get())) { | 78 if (geometry_->hasButtons(scrollbar_.get())) { |
| 77 gfx::Rect back_button_start_paint_rect = | 79 gfx::Rect back_button_start_paint_rect = |
| 78 geometry_->backButtonStartRect(scrollbar_.get()); | 80 geometry_->backButtonStartRect(scrollbar_.get()); |
| 79 painter_.paintBackButtonStart(canvas, back_button_start_paint_rect); | 81 painter_.paintBackButtonStart(canvas, back_button_start_paint_rect); |
| 80 | 82 |
| 81 gfx::Rect back_button_end_paint_rect = | 83 gfx::Rect back_button_end_paint_rect = |
| 82 geometry_->backButtonEndRect(scrollbar_.get()); | 84 geometry_->backButtonEndRect(scrollbar_.get()); |
| 83 painter_.paintBackButtonEnd(canvas, back_button_end_paint_rect); | 85 painter_.paintBackButtonEnd(canvas, back_button_end_paint_rect); |
| 84 | 86 |
| 85 gfx::Rect forward_button_start_paint_rect = | 87 gfx::Rect forward_button_start_paint_rect = |
| 86 geometry_->forwardButtonStartRect(scrollbar_.get()); | 88 geometry_->forwardButtonStartRect(scrollbar_.get()); |
| 87 painter_.paintForwardButtonStart(canvas, | 89 painter_.paintForwardButtonStart(canvas, forward_button_start_paint_rect); |
| 88 forward_button_start_paint_rect); | |
| 89 | 90 |
| 90 gfx::Rect forward_button_end_paint_rect = | 91 gfx::Rect forward_button_end_paint_rect = |
| 91 geometry_->forwardButtonEndRect(scrollbar_.get()); | 92 geometry_->forwardButtonEndRect(scrollbar_.get()); |
| 92 painter_.paintForwardButtonEnd(canvas, forward_button_end_paint_rect); | 93 painter_.paintForwardButtonEnd(canvas, forward_button_end_paint_rect); |
| 93 } | 94 } |
| 94 | 95 |
| 95 gfx::Rect track_paint_rect = geometry_->trackRect(scrollbar_.get()); | 96 gfx::Rect track_paint_rect = geometry_->trackRect(scrollbar_.get()); |
| 96 painter_.paintTrackBackground(canvas, track_paint_rect); | 97 painter_.paintTrackBackground(canvas, track_paint_rect); |
| 97 | 98 |
| 98 bool thumb_present = geometry_->hasThumb(scrollbar_.get()); | 99 bool thumb_present = geometry_->hasThumb(scrollbar_.get()); |
| 99 if (thumb_present) { | 100 if (thumb_present) { |
| 100 painter_.paintForwardTrackPart(canvas, track_paint_rect); | 101 painter_.paintForwardTrackPart(canvas, track_paint_rect); |
| 101 painter_.paintBackTrackPart(canvas, track_paint_rect); | 102 painter_.paintBackTrackPart(canvas, track_paint_rect); |
| 102 } | 103 } |
| 103 | 104 |
| 104 painter_.paintTickmarks(canvas, track_paint_rect); | 105 painter_.paintTickmarks(canvas, track_paint_rect); |
| 105 } | 106 } |
| 106 | 107 |
| 107 } // namespace webkit | 108 } // namespace content |
| 109 |
| OLD | NEW |