OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "content/browser/web_contents/aura/gesture_nav_simple.h" | 5 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
6 | 6 |
7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/renderer_host/overscroll_controller.h" | 9 #include "content/browser/renderer_host/overscroll_controller.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 // A layer delegate that paints the shield with the arrow in it. | 72 // A layer delegate that paints the shield with the arrow in it. |
73 class ArrowLayerDelegate : public ui::LayerDelegate { | 73 class ArrowLayerDelegate : public ui::LayerDelegate { |
74 public: | 74 public: |
75 explicit ArrowLayerDelegate(int resource_id) | 75 explicit ArrowLayerDelegate(int resource_id) |
76 : image_(GetContentClient()->GetNativeImageNamed(resource_id)), | 76 : image_(GetContentClient()->GetNativeImageNamed(resource_id)), |
77 left_arrow_(resource_id == IDR_BACK_ARROW) { | 77 left_arrow_(resource_id == IDR_BACK_ARROW) { |
78 CHECK(!image_.IsEmpty()); | 78 CHECK(!image_.IsEmpty()); |
79 } | 79 } |
80 | 80 |
81 virtual ~ArrowLayerDelegate() {} | 81 ~ArrowLayerDelegate() override {} |
82 | 82 |
83 bool left() const { return left_arrow_; } | 83 bool left() const { return left_arrow_; } |
84 | 84 |
85 private: | 85 private: |
86 // ui::LayerDelegate: | 86 // ui::LayerDelegate: |
87 virtual void OnPaintLayer(gfx::Canvas* canvas) override { | 87 void OnPaintLayer(gfx::Canvas* canvas) override { |
88 SkPaint paint; | 88 SkPaint paint; |
89 paint.setColor(SkColorSetARGB(0xa0, 0, 0, 0)); | 89 paint.setColor(SkColorSetARGB(0xa0, 0, 0, 0)); |
90 paint.setStyle(SkPaint::kFill_Style); | 90 paint.setStyle(SkPaint::kFill_Style); |
91 paint.setAntiAlias(true); | 91 paint.setAntiAlias(true); |
92 | 92 |
93 canvas->DrawCircle( | 93 canvas->DrawCircle( |
94 gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2), | 94 gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2), |
95 kArrowWidth, | 95 kArrowWidth, |
96 paint); | 96 paint); |
97 canvas->DrawImageInt(*image_.ToImageSkia(), | 97 canvas->DrawImageInt(*image_.ToImageSkia(), |
98 left_arrow_ ? 0 : kArrowWidth - image_.Width(), | 98 left_arrow_ ? 0 : kArrowWidth - image_.Width(), |
99 (kArrowHeight - image_.Height()) / 2); | 99 (kArrowHeight - image_.Height()) / 2); |
100 } | 100 } |
101 | 101 |
102 virtual void OnDelegatedFrameDamage( | 102 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
103 const gfx::Rect& damage_rect_in_dip) override {} | |
104 | 103 |
105 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override {} | 104 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
106 | 105 |
107 virtual base::Closure PrepareForLayerBoundsChange() override { | 106 base::Closure PrepareForLayerBoundsChange() override { |
108 return base::Closure(); | 107 return base::Closure(); |
109 } | 108 } |
110 | 109 |
111 const gfx::Image& image_; | 110 const gfx::Image& image_; |
112 const bool left_arrow_; | 111 const bool left_arrow_; |
113 | 112 |
114 DISALLOW_COPY_AND_ASSIGN(ArrowLayerDelegate); | 113 DISALLOW_COPY_AND_ASSIGN(ArrowLayerDelegate); |
115 }; | 114 }; |
116 | 115 |
117 GestureNavSimple::GestureNavSimple(WebContentsImpl* web_contents) | 116 GestureNavSimple::GestureNavSimple(WebContentsImpl* web_contents) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 clip_layer_->SetBounds(window->layer()->bounds()); | 226 clip_layer_->SetBounds(window->layer()->bounds()); |
228 clip_layer_->SetMasksToBounds(true); | 227 clip_layer_->SetMasksToBounds(true); |
229 clip_layer_->Add(arrow_.get()); | 228 clip_layer_->Add(arrow_.get()); |
230 | 229 |
231 ui::Layer* parent = window->layer()->parent(); | 230 ui::Layer* parent = window->layer()->parent(); |
232 parent->Add(clip_layer_.get()); | 231 parent->Add(clip_layer_.get()); |
233 parent->StackAtTop(clip_layer_.get()); | 232 parent->StackAtTop(clip_layer_.get()); |
234 } | 233 } |
235 | 234 |
236 } // namespace content | 235 } // namespace content |
OLD | NEW |