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); | |
263 aura::client::ScreenPositionClient* screen_position_client = | 258 aura::client::ScreenPositionClient* screen_position_client = |
264 aura::client::GetScreenPositionClient(root); | 259 aura::client::GetScreenPositionClient(window->GetRootWindow()); |
265 if (screen_position_client) | 260 if (screen_position_client) |
266 screen_position_client->ConvertPointToScreen(root, point); | 261 screen_position_client->ConvertPointToScreen(window, point); |
267 } | 262 } |
268 | 263 |
269 void TouchEditableImplAura::ConvertPointFromScreen(gfx::Point* point) { | 264 void TouchEditableImplAura::ConvertPointFromScreen(gfx::Point* point) { |
270 if (!rwhva_) | 265 if (!rwhva_) |
271 return; | 266 return; |
272 aura::Window* window = rwhva_->GetNativeView(); | 267 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. | |
278 aura::client::ScreenPositionClient* screen_position_client = | 268 aura::client::ScreenPositionClient* screen_position_client = |
279 aura::client::GetScreenPositionClient(root); | 269 aura::client::GetScreenPositionClient(window->GetRootWindow()); |
280 if (screen_position_client) | 270 if (screen_position_client) |
281 screen_position_client->ConvertPointFromScreen(root, point); | 271 screen_position_client->ConvertPointFromScreen(window, point); |
282 aura::Window::ConvertPointToTarget(root, window, point); | |
283 } | 272 } |
284 | 273 |
285 bool TouchEditableImplAura::DrawsHandles() { | 274 bool TouchEditableImplAura::DrawsHandles() { |
286 return false; | 275 return false; |
287 } | 276 } |
288 | 277 |
289 void TouchEditableImplAura::OpenContextMenu(const gfx::Point& anchor) { | 278 void TouchEditableImplAura::OpenContextMenu(const gfx::Point& anchor) { |
290 if (!rwhva_) | 279 if (!rwhva_) |
291 return; | 280 return; |
292 gfx::Point point = anchor; | 281 gfx::Point point = anchor; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 } | 375 } |
387 text_input_type_ = ui::TEXT_INPUT_TYPE_NONE; | 376 text_input_type_ = ui::TEXT_INPUT_TYPE_NONE; |
388 EndTouchEditing(true); | 377 EndTouchEditing(true); |
389 selection_gesture_in_process_ = false; | 378 selection_gesture_in_process_ = false; |
390 handles_hidden_due_to_scroll_ = false; | 379 handles_hidden_due_to_scroll_ = false; |
391 scroll_in_progress_ = false; | 380 scroll_in_progress_ = false; |
392 overscroll_in_progress_ = false; | 381 overscroll_in_progress_ = false; |
393 } | 382 } |
394 | 383 |
395 } // namespace content | 384 } // namespace content |
OLD | NEW |