summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-19 18:30:59 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-19 18:30:59 +0000
commitb6e7685790775ed48d22dd5c3e3d1979b6ff3eb2 (patch)
tree9fab989773b9dd4b1680246bd8c74603a97cb902 /ui
parent39fa84d463534eb87f9dd055a27c448d42990fa3 (diff)
downloadchromium_src-b6e7685790775ed48d22dd5c3e3d1979b6ff3eb2.zip
chromium_src-b6e7685790775ed48d22dd5c3e3d1979b6ff3eb2.tar.gz
chromium_src-b6e7685790775ed48d22dd5c3e3d1979b6ff3eb2.tar.bz2
ui: Remove platform-specific operator=()s from gfx::Rect.
These operators are making it super difficult to gradually port cc/ over to use gfx types. We are currently using IntRects in cc/ which have platform-specific cast operators. We subclass IntRect to make a cast operator to gfx::Rect, so that we can transition everything from IntRect to gfx::Rect in pieces instead of the entire codebase in one go. But then, when you write IntRect i; gfx::Rect r = i; the compiler is not sure if it should cast IntRect=>Rect and assign, or cast IntRect=>CGRect and assign. Since there are explicit constructor for these types anyhow, you can change CGRect cg; gfx::Rect r = cg; to be CGRect cg; gfx::Rect r(cg); or gfx::Rect r = gfx::Rect(cg); and retain the same functionality. But by being explicit we don't confuse the compiler. BUG=152473 R=sky Review URL: https://chromiumcodereview.appspot.com/11195056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/rect.cc24
-rw-r--r--ui/gfx/rect.h8
-rw-r--r--ui/views/widget/native_widget_win.cc2
-rw-r--r--ui/views/win/hwnd_message_handler.cc4
4 files changed, 3 insertions, 35 deletions
diff --git a/ui/gfx/rect.cc b/ui/gfx/rect.cc
index 8fc2cfb..b46a9d7 100644
--- a/ui/gfx/rect.cc
+++ b/ui/gfx/rect.cc
@@ -48,42 +48,18 @@ Rect::Rect(const RECT& r)
set_width(std::abs(r.right - r.left));
set_height(std::abs(r.bottom - r.top));
}
-
-Rect& Rect::operator=(const RECT& r) {
- set_x(r.left);
- set_y(r.top);
- set_width(std::abs(r.right - r.left));
- set_height(std::abs(r.bottom - r.top));
- return *this;
-}
#elif defined(OS_MACOSX)
Rect::Rect(const CGRect& r)
: RectBaseT(gfx::Point(r.origin.x, r.origin.y)) {
set_width(r.size.width);
set_height(r.size.height);
}
-
-Rect& Rect::operator=(const CGRect& r) {
- set_x(r.origin.x);
- set_y(r.origin.y);
- set_width(r.size.width);
- set_height(r.size.height);
- return *this;
-}
#elif defined(TOOLKIT_GTK)
Rect::Rect(const GdkRectangle& r)
: RectBaseT(gfx::Point(r.x, r.y)) {
set_width(r.width);
set_height(r.height);
}
-
-Rect& Rect::operator=(const GdkRectangle& r) {
- set_x(r.x);
- set_y(r.y);
- set_width(r.width);
- set_height(r.height);
- return *this;
-}
#endif
#if defined(OS_WIN)
diff --git a/ui/gfx/rect.h b/ui/gfx/rect.h
index 0f07948..7d73f4d8 100644
--- a/ui/gfx/rect.h
+++ b/ui/gfx/rect.h
@@ -51,14 +51,6 @@ class UI_EXPORT Rect : public RectBase<Rect, Point, Size, Insets, int> {
~Rect();
#if defined(OS_WIN)
- Rect& operator=(const RECT& r);
-#elif defined(OS_MACOSX)
- Rect& operator=(const CGRect& r);
-#elif defined(TOOLKIT_GTK)
- Rect& operator=(const GdkRectangle& r);
-#endif
-
-#if defined(OS_WIN)
// Construct an equivalent Win32 RECT object.
RECT ToRECT() const;
#elif defined(TOOLKIT_GTK)
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index b51ed01..72d15c5 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -901,7 +901,7 @@ bool Widget::ConvertRect(const Widget* source,
if (::MapWindowPoints(source_hwnd, target_hwnd,
reinterpret_cast<LPPOINT>(&win_rect),
sizeof(RECT)/sizeof(POINT))) {
- *rect = win_rect;
+ *rect = gfx::Rect(win_rect);
return true;
}
return false;
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index fe19cdb..c52deb5 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -176,8 +176,8 @@ bool GetMonitorAndRects(const RECT& rect,
MONITORINFO monitor_info = { 0 };
monitor_info.cbSize = sizeof(monitor_info);
GetMonitorInfo(*monitor, &monitor_info);
- *monitor_rect = monitor_info.rcMonitor;
- *work_area = monitor_info.rcWork;
+ *monitor_rect = gfx::Rect(monitor_info.rcMonitor);
+ *work_area = gfx::Rect(monitor_info.rcWork);
return true;
}