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 "content/browser/web_contents/touch_editable_impl_aura.h" | 5 #include "content/browser/web_contents/touch_editable_impl_aura.h" |
6 | 6 |
7 #include "content/browser/renderer_host/render_widget_host_impl.h" | 7 #include "content/browser/renderer_host/render_widget_host_impl.h" |
8 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 8 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 | 249 |
250 gfx::NativeView TouchEditableImplAura::GetNativeView() const { | 250 gfx::NativeView TouchEditableImplAura::GetNativeView() const { |
251 return rwhva_ ? rwhva_->GetNativeView()->GetToplevelWindow() : NULL; | 251 return rwhva_ ? rwhva_->GetNativeView()->GetToplevelWindow() : NULL; |
252 } | 252 } |
253 | 253 |
254 void TouchEditableImplAura::ConvertPointToScreen(gfx::Point* point) { | 254 void TouchEditableImplAura::ConvertPointToScreen(gfx::Point* point) { |
255 if (!rwhva_) | 255 if (!rwhva_) |
256 return; | 256 return; |
257 aura::Window* window = rwhva_->GetNativeView(); | 257 aura::Window* window = rwhva_->GetNativeView(); |
| 258 aura::Window* root = window->GetRootWindow(); |
| 259 |
| 260 // First convert the point to root window coordinates, then if there is a |
| 261 // screen position client, convert it to screen coordinates. |
| 262 aura::Window::ConvertPointToTarget(window, root, point); |
258 aura::client::ScreenPositionClient* screen_position_client = | 263 aura::client::ScreenPositionClient* screen_position_client = |
259 aura::client::GetScreenPositionClient(window->GetRootWindow()); | 264 aura::client::GetScreenPositionClient(root); |
260 if (screen_position_client) | 265 if (screen_position_client) |
261 screen_position_client->ConvertPointToScreen(window, point); | 266 screen_position_client->ConvertPointToScreen(root, point); |
262 } | 267 } |
263 | 268 |
264 void TouchEditableImplAura::ConvertPointFromScreen(gfx::Point* point) { | 269 void TouchEditableImplAura::ConvertPointFromScreen(gfx::Point* point) { |
265 if (!rwhva_) | 270 if (!rwhva_) |
266 return; | 271 return; |
267 aura::Window* window = rwhva_->GetNativeView(); | 272 aura::Window* window = rwhva_->GetNativeView(); |
| 273 aura::Window* root = window->GetRootWindow(); |
| 274 |
| 275 // If there is a screen position client, convert the point from screen to root |
| 276 // window and then to client coordinates. Otherwise, suppose the point is in |
| 277 // root window coordinates and convert it to client coordinates. |
268 aura::client::ScreenPositionClient* screen_position_client = | 278 aura::client::ScreenPositionClient* screen_position_client = |
269 aura::client::GetScreenPositionClient(window->GetRootWindow()); | 279 aura::client::GetScreenPositionClient(root); |
270 if (screen_position_client) | 280 if (screen_position_client) |
271 screen_position_client->ConvertPointFromScreen(window, point); | 281 screen_position_client->ConvertPointFromScreen(root, point); |
| 282 aura::Window::ConvertPointToTarget(root, window, point); |
272 } | 283 } |
273 | 284 |
274 bool TouchEditableImplAura::DrawsHandles() { | 285 bool TouchEditableImplAura::DrawsHandles() { |
275 return false; | 286 return false; |
276 } | 287 } |
277 | 288 |
278 void TouchEditableImplAura::OpenContextMenu(const gfx::Point& anchor) { | 289 void TouchEditableImplAura::OpenContextMenu(const gfx::Point& anchor) { |
279 if (!rwhva_) | 290 if (!rwhva_) |
280 return; | 291 return; |
281 gfx::Point point = anchor; | 292 gfx::Point point = anchor; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 386 } |
376 text_input_type_ = ui::TEXT_INPUT_TYPE_NONE; | 387 text_input_type_ = ui::TEXT_INPUT_TYPE_NONE; |
377 EndTouchEditing(true); | 388 EndTouchEditing(true); |
378 selection_gesture_in_process_ = false; | 389 selection_gesture_in_process_ = false; |
379 handles_hidden_due_to_scroll_ = false; | 390 handles_hidden_due_to_scroll_ = false; |
380 scroll_in_progress_ = false; | 391 scroll_in_progress_ = false; |
381 overscroll_in_progress_ = false; | 392 overscroll_in_progress_ = false; |
382 } | 393 } |
383 | 394 |
384 } // namespace content | 395 } // namespace content |
OLD | NEW |