OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/views/touchui/touch_selection_controller_impl.h" | 5 #include "ui/views/touchui/touch_selection_controller_impl.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "ui/aura/client/cursor_client.h" | 8 #include "ui/aura/client/cursor_client.h" |
9 #include "ui/aura/env.h" | 9 #include "ui/aura/env.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 image_(GetCenterHandleImage()), | 232 image_(GetCenterHandleImage()), |
233 is_cursor_handle_(is_cursor_handle), | 233 is_cursor_handle_(is_cursor_handle), |
234 draw_invisible_(false) { | 234 draw_invisible_(false) { |
235 widget_.reset(CreateTouchSelectionPopupWidget(context, this)); | 235 widget_.reset(CreateTouchSelectionPopupWidget(context, this)); |
236 widget_->SetContentsView(this); | 236 widget_->SetContentsView(this); |
237 | 237 |
238 aura::Window* window = widget_->GetNativeWindow(); | 238 aura::Window* window = widget_->GetNativeWindow(); |
239 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( | 239 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( |
240 new TouchHandleWindowTargeter(window, this))); | 240 new TouchHandleWindowTargeter(window, this))); |
241 | 241 |
242 // We are owned by the TouchSelectionController. | 242 // We are owned by the TouchSelectionControllerImpl. |
243 set_owned_by_client(); | 243 set_owned_by_client(); |
244 } | 244 } |
245 | 245 |
246 ~EditingHandleView() override { SetWidgetVisible(false, false); } | 246 ~EditingHandleView() override { SetWidgetVisible(false, false); } |
247 | 247 |
248 // Overridden from views::WidgetDelegateView: | 248 // Overridden from views::WidgetDelegateView: |
249 bool WidgetHasHitTestMask() const override { return true; } | 249 bool WidgetHasHitTestMask() const override { return true; } |
250 | 250 |
251 void GetWidgetHitTestMask(gfx::Path* mask) const override { | 251 void GetWidgetHitTestMask(gfx::Path* mask) const override { |
252 gfx::Size image_size = image_->Size(); | 252 gfx::Size image_size = image_->Size(); |
253 mask->addRect( | 253 mask->addRect( |
254 SkIntToScalar(0), | 254 SkIntToScalar(0), |
255 SkIntToScalar(selection_bound_.GetHeight() + | 255 SkIntToScalar(selection_bound_.GetHeight() + |
256 kSelectionHandleVerticalVisualOffset), | 256 kSelectionHandleVerticalVisualOffset), |
257 SkIntToScalar(image_size.width()) + 2 * kSelectionHandleHorizPadding, | 257 SkIntToScalar(image_size.width()) + 2 * kSelectionHandleHorizPadding, |
258 SkIntToScalar(selection_bound_.GetHeight() + | 258 SkIntToScalar(selection_bound_.GetHeight() + |
259 kSelectionHandleVerticalVisualOffset + | 259 kSelectionHandleVerticalVisualOffset + |
260 image_size.height() + kSelectionHandleVertPadding)); | 260 image_size.height() + kSelectionHandleVertPadding)); |
261 } | 261 } |
262 | 262 |
263 void DeleteDelegate() override { | 263 void DeleteDelegate() override { |
264 // We are owned and deleted by TouchSelectionController. | 264 // We are owned and deleted by TouchSelectionControllerImpl. |
265 } | 265 } |
266 | 266 |
267 // Overridden from views::View: | 267 // Overridden from views::View: |
268 void OnPaint(gfx::Canvas* canvas) override { | 268 void OnPaint(gfx::Canvas* canvas) override { |
269 if (draw_invisible_) | 269 if (draw_invisible_) |
270 return; | 270 return; |
271 | 271 |
272 // Draw the handle image. | 272 // Draw the handle image. |
273 canvas->DrawImageInt( | 273 canvas->DrawImageInt( |
274 *image_->ToImageSkia(), | 274 *image_->ToImageSkia(), |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 | 735 |
736 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { | 736 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { |
737 return selection_handle_1_.get(); | 737 return selection_handle_1_.get(); |
738 } | 738 } |
739 | 739 |
740 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { | 740 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { |
741 return selection_handle_2_.get(); | 741 return selection_handle_2_.get(); |
742 } | 742 } |
743 | 743 |
744 } // namespace views | 744 } // namespace views |
OLD | NEW |