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 if (selection_bound_.type() == gfx::SelectionBound::EMPTY) | |
sky
2016/10/06 16:49:20
It would be nice if you had a comment as to why th
Evan Stade
2016/10/06 16:51:44
Done.
| |
324 return gfx::Size(); | |
324 return GetSelectionWidgetBounds(selection_bound_).size(); | 325 return GetSelectionWidgetBounds(selection_bound_).size(); |
325 } | 326 } |
326 | 327 |
327 bool IsWidgetVisible() const { | 328 bool IsWidgetVisible() const { |
328 return widget_->IsVisible(); | 329 return widget_->IsVisible(); |
329 } | 330 } |
330 | 331 |
331 void SetWidgetVisible(bool visible, bool quick) { | 332 void SetWidgetVisible(bool visible, bool quick) { |
332 if (widget_->IsVisible() == visible) | 333 if (widget_->IsVisible() == visible) |
333 return; | 334 return; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
787 | 788 |
788 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { | 789 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle1View() { |
789 return selection_handle_1_.get(); | 790 return selection_handle_1_.get(); |
790 } | 791 } |
791 | 792 |
792 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { | 793 views::WidgetDelegateView* TouchSelectionControllerImpl::GetHandle2View() { |
793 return selection_handle_2_.get(); | 794 return selection_handle_2_.get(); |
794 } | 795 } |
795 | 796 |
796 } // namespace views | 797 } // namespace views |
OLD | NEW |