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/macros.h" | 7 #include "base/macros.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 public: | 230 public: |
231 EditingHandleView(TouchSelectionControllerImpl* controller, | 231 EditingHandleView(TouchSelectionControllerImpl* controller, |
232 gfx::NativeView context, | 232 gfx::NativeView context, |
233 bool is_cursor_handle) | 233 bool is_cursor_handle) |
234 : controller_(controller), | 234 : controller_(controller), |
235 image_(GetCenterHandleImage()), | 235 image_(GetCenterHandleImage()), |
236 is_cursor_handle_(is_cursor_handle), | 236 is_cursor_handle_(is_cursor_handle), |
237 draw_invisible_(false), | 237 draw_invisible_(false), |
238 weak_ptr_factory_(this) { | 238 weak_ptr_factory_(this) { |
239 widget_.reset(CreateTouchSelectionPopupWidget(context, this)); | 239 widget_.reset(CreateTouchSelectionPopupWidget(context, this)); |
240 widget_->SetContentsView(this); | |
241 | 240 |
242 aura::Window* window = widget_->GetNativeWindow(); | 241 aura::Window* window = widget_->GetNativeWindow(); |
243 window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 242 window->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
244 new TouchHandleWindowTargeter(window, this))); | 243 new TouchHandleWindowTargeter(window, this))); |
245 | 244 |
246 // We are owned by the TouchSelectionControllerImpl. | 245 // We are owned by the TouchSelectionControllerImpl. |
247 set_owned_by_client(); | 246 set_owned_by_client(); |
248 } | 247 } |
249 | 248 |
250 ~EditingHandleView() override { SetWidgetVisible(false, false); } | 249 ~EditingHandleView() override { SetWidgetVisible(false, false); } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 CHECK(weak_ptr); | 313 CHECK(weak_ptr); |
315 controller_->SetDraggingHandle(nullptr); | 314 controller_->SetDraggingHandle(nullptr); |
316 break; | 315 break; |
317 } | 316 } |
318 default: | 317 default: |
319 break; | 318 break; |
320 } | 319 } |
321 } | 320 } |
322 | 321 |
323 gfx::Size GetPreferredSize() const override { | 322 gfx::Size GetPreferredSize() const override { |
| 323 // This function will be called during widget initialization, i.e. before |
| 324 // SetBoundInScreen has been called. No-op in that case. |
| 325 if (selection_bound_.type() == gfx::SelectionBound::EMPTY) |
| 326 return gfx::Size(); |
324 return GetSelectionWidgetBounds(selection_bound_).size(); | 327 return GetSelectionWidgetBounds(selection_bound_).size(); |
325 } | 328 } |
326 | 329 |
327 bool IsWidgetVisible() const { | 330 bool IsWidgetVisible() const { |
328 return widget_->IsVisible(); | 331 return widget_->IsVisible(); |
329 } | 332 } |
330 | 333 |
331 void SetWidgetVisible(bool visible, bool quick) { | 334 void SetWidgetVisible(bool visible, bool quick) { |
332 if (widget_->IsVisible() == visible) | 335 if (widget_->IsVisible() == visible) |
333 return; | 336 return; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 | 790 |
788 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { | 791 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { |
789 return selection_handle_1_.get(); | 792 return selection_handle_1_.get(); |
790 } | 793 } |
791 | 794 |
792 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { | 795 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { |
793 return selection_handle_2_.get(); | 796 return selection_handle_2_.get(); |
794 } | 797 } |
795 | 798 |
796 } // namespace views | 799 } // namespace views |
OLD | NEW |