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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 if (result) | 425 if (result) |
| 426 return result; | 426 return result; |
| 427 } | 427 } |
| 428 return NULL; | 428 return NULL; |
| 429 } | 429 } |
| 430 | 430 |
| 431 // static | 431 // static |
| 432 void Window::ConvertPointToTarget(const Window* source, | 432 void Window::ConvertPointToTarget(const Window* source, |
| 433 const Window* target, | 433 const Window* target, |
| 434 gfx::Point* point) { | 434 gfx::Point* point) { |
| 435 gfx::PointF point_f(*point); | |
| 436 ConvertPointToTargetF(source, target, &point_f); | |
| 437 *point = gfx::ToFlooredPoint(point_f); | |
| 438 } | |
| 439 | |
| 440 // static | |
| 441 void Window::ConvertPointToTargetF(const Window* source, | |
| 442 const Window* target, | |
| 443 gfx::PointF* point) { | |
| 435 if (!source) | 444 if (!source) |
| 436 return; | 445 return; |
| 437 if (source->GetRootWindow() != target->GetRootWindow()) { | 446 if (source->GetRootWindow() != target->GetRootWindow()) { |
| 447 gfx::Point floored = gfx::ToFlooredPoint(*point); | |
|
tdresser
2017/01/20 16:07:48
Do we need to floor in this case?
denniskempin
2017/01/20 18:26:33
I am flooring here to be able to pass a Point into
| |
| 438 client::ScreenPositionClient* source_client = | 448 client::ScreenPositionClient* source_client = |
| 439 client::GetScreenPositionClient(source->GetRootWindow()); | 449 client::GetScreenPositionClient(source->GetRootWindow()); |
| 440 // |source_client| can be NULL in tests. | 450 // |source_client| can be NULL in tests. |
| 441 if (source_client) | 451 if (source_client) |
| 442 source_client->ConvertPointToScreen(source, point); | 452 source_client->ConvertPointToScreen(source, &floored); |
| 443 | 453 |
| 444 client::ScreenPositionClient* target_client = | 454 client::ScreenPositionClient* target_client = |
| 445 client::GetScreenPositionClient(target->GetRootWindow()); | 455 client::GetScreenPositionClient(target->GetRootWindow()); |
| 446 // |target_client| can be NULL in tests. | 456 // |target_client| can be NULL in tests. |
| 447 if (target_client) | 457 if (target_client) |
| 448 target_client->ConvertPointFromScreen(target, point); | 458 target_client->ConvertPointFromScreen(target, &floored); |
| 459 | |
| 460 *point = gfx::PointF(floored); | |
| 449 } else { | 461 } else { |
| 450 ui::Layer::ConvertPointToLayer(source->layer(), target->layer(), point); | 462 ui::Layer::ConvertPointToLayerF(source->layer(), target->layer(), point); |
| 451 } | 463 } |
| 452 } | 464 } |
| 453 | 465 |
| 454 // static | 466 // static |
| 455 void Window::ConvertRectToTarget(const Window* source, | 467 void Window::ConvertRectToTarget(const Window* source, |
| 456 const Window* target, | 468 const Window* target, |
| 457 gfx::Rect* rect) { | 469 gfx::Rect* rect) { |
| 458 DCHECK(rect); | 470 DCHECK(rect); |
| 459 gfx::Point origin = rect->origin(); | 471 gfx::Point origin = rect->origin(); |
| 460 ConvertPointToTarget(source, target, &origin); | 472 ConvertPointToTarget(source, target, &origin); |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1118 layer_name = "Unnamed Window"; | 1130 layer_name = "Unnamed Window"; |
| 1119 | 1131 |
| 1120 if (id_ != -1) | 1132 if (id_ != -1) |
| 1121 layer_name += " " + base::IntToString(id_); | 1133 layer_name += " " + base::IntToString(id_); |
| 1122 | 1134 |
| 1123 layer()->set_name(layer_name); | 1135 layer()->set_name(layer_name); |
| 1124 #endif | 1136 #endif |
| 1125 } | 1137 } |
| 1126 | 1138 |
| 1127 } // namespace aura | 1139 } // namespace aura |
| OLD | NEW |