Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 | 543 |
| 544 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { | 544 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { |
| 545 if (web_contents_->GetInterstitialPage()) | 545 if (web_contents_->GetInterstitialPage()) |
| 546 web_contents_->GetInterstitialPage()->SetSize(size); | 546 web_contents_->GetInterstitialPage()->SetSize(size); |
| 547 RenderWidgetHostView* rwhv = | 547 RenderWidgetHostView* rwhv = |
| 548 web_contents_->GetRenderWidgetHostView(); | 548 web_contents_->GetRenderWidgetHostView(); |
| 549 if (rwhv) | 549 if (rwhv) |
| 550 rwhv->SetSize(size); | 550 rwhv->SetSize(size); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { | 553 void WebContentsViewAura::EndDrag(RenderWidgetHost* source_rwh, |
| 554 blink::WebDragOperationsMask ops) { | |
| 554 if (!web_contents_) | 555 if (!web_contents_) |
| 555 return; | 556 return; |
| 556 | 557 |
| 557 aura::Window* window = GetContentNativeView(); | 558 aura::Window* window = GetContentNativeView(); |
| 558 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); | 559 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 559 gfx::Point client_loc = screen_loc; | 560 gfx::Point client_loc = screen_loc; |
| 560 aura::client::ScreenPositionClient* screen_position_client = | 561 aura::client::ScreenPositionClient* screen_position_client = |
| 561 aura::client::GetScreenPositionClient(window->GetRootWindow()); | 562 aura::client::GetScreenPositionClient(window->GetRootWindow()); |
| 562 if (screen_position_client) | 563 if (screen_position_client) |
| 563 screen_position_client->ConvertPointFromScreen(window, &client_loc); | 564 screen_position_client->ConvertPointFromScreen(window, &client_loc); |
| 564 | 565 |
| 565 // TODO(paulmeyer): In the OOPIF case, should |client_loc| be converted to | 566 // TODO(paulmeyer): In the OOPIF case, should |client_loc| be converted to |
| 566 // the coordinates local to |drag_start_rwh_|? See crbug.com/647249. | 567 // the coordinates local to |drag_start_rwh_|? See crbug.com/647249. |
| 567 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), | 568 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
| 568 screen_loc.x(), screen_loc.y(), ops, | 569 screen_loc.x(), screen_loc.y(), ops, |
| 569 drag_start_rwh_.get()); | 570 source_rwh); |
| 570 } | 571 } |
| 571 | 572 |
| 572 void WebContentsViewAura::InstallOverscrollControllerDelegate( | 573 void WebContentsViewAura::InstallOverscrollControllerDelegate( |
| 573 RenderWidgetHostViewAura* view) { | 574 RenderWidgetHostViewAura* view) { |
| 574 const std::string value = base::CommandLine::ForCurrentProcess()-> | 575 const std::string value = base::CommandLine::ForCurrentProcess()-> |
| 575 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); | 576 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); |
| 576 if (value == "0") { | 577 if (value == "0") { |
| 577 navigation_overlay_.reset(); | 578 navigation_overlay_.reset(); |
| 578 return; | 579 return; |
| 579 } | 580 } |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 const gfx::ImageSkia& image, | 890 const gfx::ImageSkia& image, |
| 890 const gfx::Vector2d& image_offset, | 891 const gfx::Vector2d& image_offset, |
| 891 const DragEventSourceInfo& event_info, | 892 const DragEventSourceInfo& event_info, |
| 892 RenderWidgetHostImpl* source_rwh) { | 893 RenderWidgetHostImpl* source_rwh) { |
| 893 aura::Window* root_window = GetNativeView()->GetRootWindow(); | 894 aura::Window* root_window = GetNativeView()->GetRootWindow(); |
| 894 if (!aura::client::GetDragDropClient(root_window)) { | 895 if (!aura::client::GetDragDropClient(root_window)) { |
| 895 web_contents_->SystemDragEnded(source_rwh); | 896 web_contents_->SystemDragEnded(source_rwh); |
| 896 return; | 897 return; |
| 897 } | 898 } |
| 898 | 899 |
| 899 drag_start_rwh_ = source_rwh->GetWeakPtr(); | 900 auto source_rwh_weak_ptr = source_rwh->GetWeakPtr(); |
|
Łukasz Anforowicz
2016/12/01 20:22:46
Could you please add a comment explaining why we n
lfg
2016/12/01 20:56:33
Done.
|
Łukasz Anforowicz
2016/12/01 20:22:46
nit?: I guess this is a matter of personal/subject
lfg
2016/12/01 20:56:33
I usually use auto when the type is clear (in this
Łukasz Anforowicz
2016/12/01 21:14:28
Thanks. The WeakPtr part was obvious, but it wasn
|
| 900 | 901 |
| 901 ui::TouchSelectionController* selection_controller = GetSelectionController(); | 902 ui::TouchSelectionController* selection_controller = GetSelectionController(); |
| 902 if (selection_controller) | 903 if (selection_controller) |
| 903 selection_controller->HideAndDisallowShowingAutomatically(); | 904 selection_controller->HideAndDisallowShowingAutomatically(); |
| 904 std::unique_ptr<ui::OSExchangeData::Provider> provider = | 905 std::unique_ptr<ui::OSExchangeData::Provider> provider = |
| 905 ui::OSExchangeDataProviderFactory::CreateProvider(); | 906 ui::OSExchangeDataProviderFactory::CreateProvider(); |
| 906 PrepareDragData(drop_data, provider.get(), web_contents_); | 907 PrepareDragData(drop_data, provider.get(), web_contents_); |
| 907 | 908 |
| 908 ui::OSExchangeData data( | 909 ui::OSExchangeData data( |
| 909 std::move(provider)); // takes ownership of |provider|. | 910 std::move(provider)); // takes ownership of |provider|. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 933 // Bail out immediately if the contents view window is gone. Note that it is | 934 // Bail out immediately if the contents view window is gone. Note that it is |
| 934 // not safe to access any class members in this case since |this| may already | 935 // not safe to access any class members in this case since |this| may already |
| 935 // be destroyed. The local variable |drag_source| will still be valid though, | 936 // be destroyed. The local variable |drag_source| will still be valid though, |
| 936 // so we can use it to determine if the window is gone. | 937 // so we can use it to determine if the window is gone. |
| 937 if (!drag_source->window()) { | 938 if (!drag_source->window()) { |
| 938 // Note that in this case, we don't need to call SystemDragEnded() since the | 939 // Note that in this case, we don't need to call SystemDragEnded() since the |
| 939 // renderer is going away. | 940 // renderer is going away. |
| 940 return; | 941 return; |
| 941 } | 942 } |
| 942 | 943 |
| 943 EndDrag(ConvertToWeb(result_op)); | 944 EndDrag(source_rwh_weak_ptr.get(), ConvertToWeb(result_op)); |
| 944 web_contents_->SystemDragEnded(source_rwh); | 945 if (web_contents_) |
|
Łukasz Anforowicz
2016/12/01 20:22:46
Oh, so this was the main problem:
- EndDrag was al
Łukasz Anforowicz
2016/12/01 20:23:45
s/not/now/ :-P
lfg
2016/12/01 20:56:33
Right, the other reason I changed EndDrag is to ge
Łukasz Anforowicz
2016/12/01 21:14:28
Yes - that makes total sense.
dcheng
2016/12/01 21:16:31
Thanks for clearing this up: it wasn't clear to me
| |
| 946 web_contents_->SystemDragEnded(source_rwh_weak_ptr.get()); | |
|
Łukasz Anforowicz
2016/12/01 20:22:46
I wonder if the call to SystemDragEnded could/shou
lfg
2016/12/01 20:56:33
Done.
| |
| 945 } | 947 } |
| 946 | 948 |
| 947 void WebContentsViewAura::UpdateDragCursor(blink::WebDragOperation operation) { | 949 void WebContentsViewAura::UpdateDragCursor(blink::WebDragOperation operation) { |
| 948 current_drag_op_ = operation; | 950 current_drag_op_ = operation; |
| 949 } | 951 } |
| 950 | 952 |
| 951 void WebContentsViewAura::GotFocus() { | 953 void WebContentsViewAura::GotFocus() { |
| 952 web_contents_->NotifyWebContentsFocused(); | 954 web_contents_->NotifyWebContentsFocused(); |
| 953 } | 955 } |
| 954 | 956 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1247 bool allow_multiple_selection) { | 1249 bool allow_multiple_selection) { |
| 1248 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; | 1250 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; |
| 1249 } | 1251 } |
| 1250 | 1252 |
| 1251 void WebContentsViewAura::HidePopupMenu() { | 1253 void WebContentsViewAura::HidePopupMenu() { |
| 1252 NOTIMPLEMENTED(); | 1254 NOTIMPLEMENTED(); |
| 1253 } | 1255 } |
| 1254 #endif | 1256 #endif |
| 1255 | 1257 |
| 1256 } // namespace content | 1258 } // namespace content |
| OLD | NEW |