summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-17 19:33:09 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-17 19:33:09 +0000
commit0a1d36b22de76ac7d8e0af2efb222c5ae85d099b (patch)
treef3c3a1bb493dd98baaec6489dcc3b35eb93694da
parent251b16cffbfca46fd038b13c702d9309d0948eb0 (diff)
downloadchromium_src-0a1d36b22de76ac7d8e0af2efb222c5ae85d099b.zip
chromium_src-0a1d36b22de76ac7d8e0af2efb222c5ae85d099b.tar.gz
chromium_src-0a1d36b22de76ac7d8e0af2efb222c5ae85d099b.tar.bz2
Convert SchedulePaint and a few other methods to use gfx types.
http://crbug.com/2186 Review URL: http://codereview.chromium.org/7468 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3550 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc7
-rw-r--r--chrome/browser/browser.h8
-rw-r--r--chrome/browser/browser_commands.cc4
-rw-r--r--chrome/browser/external_tab_container.cc5
-rw-r--r--chrome/browser/external_tab_container.h2
-rw-r--r--chrome/browser/tabs/tab_strip_model.h2
-rw-r--r--chrome/browser/views/constrained_window_impl.cc2
-rw-r--r--chrome/browser/views/old_frames/simple_vista_frame.cc2
-rw-r--r--chrome/browser/views/old_frames/simple_xp_frame.cc2
-rw-r--r--chrome/browser/views/old_frames/vista_frame.cc9
-rw-r--r--chrome/browser/views/old_frames/vista_frame.h2
-rw-r--r--chrome/browser/views/old_frames/xp_frame.cc12
-rw-r--r--chrome/browser/views/old_frames/xp_frame.h2
-rw-r--r--chrome/browser/views/tabs/dragged_tab_view.cc2
-rw-r--r--chrome/views/container.h6
-rw-r--r--chrome/views/container_win.cc15
-rw-r--r--chrome/views/container_win.h2
-rw-r--r--chrome/views/custom_frame_window.cc2
-rw-r--r--chrome/views/root_view.cc42
-rw-r--r--chrome/views/root_view.h8
-rw-r--r--chrome/views/scroll_view.cc4
-rw-r--r--chrome/views/tooltip_manager.cc4
-rw-r--r--chrome/views/view.cc23
-rw-r--r--chrome/views/view.h37
24 files changed, 90 insertions, 114 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index b9d92e4..cf88a6c 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1347,15 +1347,12 @@ TabContents* Browser::CreateTabContentsForURL(
return contents;
}
-void Browser::ShowApplicationMenu(const gfx::Point p) {
+void Browser::ShowApplicationMenu(const gfx::Point& p) {
if (!window_)
return;
HWND hwnd = reinterpret_cast<HWND>(window_->GetPlatformID());
- CPoint t;
- t.x = p.x();
- t.y = p.y();
- RunSimpleFrameMenu(t, hwnd);
+ RunSimpleFrameMenu(p, hwnd);
}
void Browser::ValidateLoadingAnimations() {
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index f57cbd4..b256e71 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -86,10 +86,6 @@ class Browser : public TabStripModelDelegate,
static void RegisterPrefs(PrefService* prefs);
static void RegisterUserPrefs(PrefService* prefs);
- // Initialize the receiver with the provided bounds which
- // is in the screen coordinate system.
- void InitWithBounds(CRect* bounds, int show_command);
-
void GoBack();
void GoForward();
void Stop();
@@ -244,7 +240,7 @@ class Browser : public TabStripModelDelegate,
PageTransition::Type transition,
bool defer_load,
SiteInstance* instance) const;
- virtual void ShowApplicationMenu(const gfx::Point p);
+ virtual void ShowApplicationMenu(const gfx::Point& p);
virtual bool CanDuplicateContentsAt(int index);
virtual void DuplicateContentsAt(int index);
virtual void ValidateLoadingAnimations();
@@ -305,7 +301,7 @@ class Browser : public TabStripModelDelegate,
// Invoke the menu we use for application and popup windows at the provided
// point and for the provided hwnd.
- void RunSimpleFrameMenu(const CPoint& pt, HWND hwnd);
+ void RunSimpleFrameMenu(const gfx::Point& pt, HWND hwnd);
// Show some native UI given a URL. If a tab with the same URL is already
// visible in this browser, it becomes selected. Otherwise a new tab is
diff --git a/chrome/browser/browser_commands.cc b/chrome/browser/browser_commands.cc
index 98f7b98..20bba20 100644
--- a/chrome/browser/browser_commands.cc
+++ b/chrome/browser/browser_commands.cc
@@ -913,7 +913,7 @@ void Browser::OpenClearBrowsingDataDialog() {
new ClearBrowsingDataView(profile_))->Show();
}
-void Browser::RunSimpleFrameMenu(const CPoint& pt, HWND hwnd) {
+void Browser::RunSimpleFrameMenu(const gfx::Point& pt, HWND hwnd) {
bool for_popup = !IsApplication();
EncodingMenuControllerDelegate d(this, &controller_);
@@ -968,7 +968,7 @@ void Browser::RunSimpleFrameMenu(const CPoint& pt, HWND hwnd) {
m.AppendSeparator();
m.AppendMenuItemWithLabel(IDC_CLOSE_WEB_APP, l10n_util::GetString(IDS_CLOSE));
- m.RunMenuAt(pt.x, pt.y);
+ m.RunMenuAt(pt.x(), pt.y());
}
void Browser::CopyCurrentURLToClipBoard() {
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 6b7c131..599ce6a 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -253,8 +253,9 @@ HWND ExternalTabContainer::GetHWND() const {
return m_hWnd;
}
-void ExternalTabContainer::PaintNow(const CRect& update_rect) {
- RedrawWindow(update_rect,
+void ExternalTabContainer::PaintNow(const gfx::Rect& update_rect) {
+ RECT native_update_rect = update_rect.ToRECT();
+ RedrawWindow(&native_update_rect,
NULL,
RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_NOERASE);
}
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index 5099958..00a52e9 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -93,7 +93,7 @@ class ExternalTabContainer : public TabContentsDelegate,
virtual void GetBounds(CRect *out, bool including_frame) const;
virtual void MoveToFront(bool should_activate);
virtual HWND GetHWND() const;
- virtual void PaintNow(const CRect& update_rect);
+ virtual void PaintNow(const gfx::Rect& update_rect);
virtual views::RootView* GetRootView();
virtual bool IsVisible();
virtual bool IsActive();
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index 76886a0..fd3a196 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -125,7 +125,7 @@ class TabStripModelDelegate {
// Show the web application context menu at the provided point. |p| is in
// screen coordinate system.
- virtual void ShowApplicationMenu(const gfx::Point p) = 0;
+ virtual void ShowApplicationMenu(const gfx::Point& p) = 0;
// Return whether some contents can be duplicated.
virtual bool CanDuplicateContentsAt(int index) = 0;
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 3f5664d..dd948b7 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -446,7 +446,7 @@ gfx::Rect ConstrainedWindowNonClientView::CalculateWindowBoundsForClientBounds(
}
void ConstrainedWindowNonClientView::UpdateWindowTitle() {
- SchedulePaint(title_bounds_.ToRECT(), false);
+ SchedulePaint(title_bounds_, false);
UpdateLocationBar();
}
diff --git a/chrome/browser/views/old_frames/simple_vista_frame.cc b/chrome/browser/views/old_frames/simple_vista_frame.cc
index 3ec7260..a34cb88 100644
--- a/chrome/browser/views/old_frames/simple_vista_frame.cc
+++ b/chrome/browser/views/old_frames/simple_vista_frame.cc
@@ -145,7 +145,7 @@ void SimpleVistaFrame::OnNCLButtonDown(UINT flags, const CPoint& pt) {
if (flags == HTSYSMENU) {
POINT p = {0, 0};
::ClientToScreen(*this, &p);
- browser_->RunSimpleFrameMenu(p, *this);
+ browser_->RunSimpleFrameMenu(gfx::Point(p.x, p.y), *this);
SetMsgHandled(true);
} else {
SetMsgHandled(false);
diff --git a/chrome/browser/views/old_frames/simple_xp_frame.cc b/chrome/browser/views/old_frames/simple_xp_frame.cc
index 8030a55..b2234e5 100644
--- a/chrome/browser/views/old_frames/simple_xp_frame.cc
+++ b/chrome/browser/views/old_frames/simple_xp_frame.cc
@@ -372,7 +372,7 @@ void SimpleXPFrame::ValidateThrobber() {
}
void SimpleXPFrame::RunMenu(const CPoint& pt, HWND hwnd) {
- browser_->RunSimpleFrameMenu(pt, hwnd);
+ browser_->RunSimpleFrameMenu(gfx::Point(pt.x, pt.y), hwnd);
}
void SimpleXPFrame::ShowTabContents(TabContents* selected_contents) {
diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc
index ed6cfe3..d671eee 100644
--- a/chrome/browser/views/old_frames/vista_frame.cc
+++ b/chrome/browser/views/old_frames/vista_frame.cc
@@ -1203,9 +1203,10 @@ HWND VistaFrame::GetHWND() const {
return m_hWnd;
}
-void VistaFrame::PaintNow(const CRect& update_rect) {
- if (!update_rect.IsRectNull() && IsVisible()) {
- RedrawWindow(update_rect,
+void VistaFrame::PaintNow(const gfx::Rect& update_rect) {
+ if (!update_rect.IsEmpty() && IsVisible()) {
+ RECT native_update_rect = update_rect.ToRECT();
+ RedrawWindow(&native_update_rect,
NULL,
RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_NOERASE);
}
@@ -1522,7 +1523,7 @@ void VistaFrame::ContinueDetachConstrainedWindowDrag(const gfx::Point& mouse_pt,
// correct. (Otherwise parts of the tabstrip are clipped).
CRect cr;
GetClientRect(&cr);
- PaintNow(cr);
+ PaintNow(gfx::Rect(cr));
// The user's mouse is already moving, and the left button is down, but we
// need to start moving this frame, so we _post_ it a NCLBUTTONDOWN message
diff --git a/chrome/browser/views/old_frames/vista_frame.h b/chrome/browser/views/old_frames/vista_frame.h
index 10d654f..ff5de5c 100644
--- a/chrome/browser/views/old_frames/vista_frame.h
+++ b/chrome/browser/views/old_frames/vista_frame.h
@@ -193,7 +193,7 @@ class VistaFrame : public BrowserWindow,
virtual void GetBounds(CRect *out, bool including_frame) const;
virtual void MoveToFront(bool should_activate);
virtual HWND GetHWND() const;
- virtual void PaintNow(const CRect& update_rect);
+ virtual void PaintNow(const gfx::Rect& update_rect);
virtual views::RootView* GetRootView();
virtual bool IsVisible();
virtual bool IsActive();
diff --git a/chrome/browser/views/old_frames/xp_frame.cc b/chrome/browser/views/old_frames/xp_frame.cc
index 9ca65f1..5720782 100644
--- a/chrome/browser/views/old_frames/xp_frame.cc
+++ b/chrome/browser/views/old_frames/xp_frame.cc
@@ -1017,7 +1017,8 @@ void XPFrame::OnSize(UINT param, const CSize& size) {
// We paint immediately during a resize because it will feel laggy otherwise.
if (root_view_.NeedsPainting(false)) {
- RedrawWindow(root_view_.GetScheduledPaintRect(),
+ RECT native_update_rect = root_view_.GetScheduledPaintRect().ToRECT();
+ RedrawWindow(&native_update_rect,
NULL,
RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN);
MessageLoopForUI::current()->PumpOutPendingPaintMessages();
@@ -1910,9 +1911,10 @@ HWND XPFrame::GetHWND() const {
return m_hWnd;
}
-void XPFrame::PaintNow(const CRect& update_rect) {
- if (!update_rect.IsRectNull() && IsVisible()) {
- RedrawWindow(update_rect,
+void XPFrame::PaintNow(const gfx::Rect& update_rect) {
+ if (!update_rect.IsEmpty() && IsVisible()) {
+ RECT native_update_rect = update_rect.ToRECT();
+ RedrawWindow(&native_update_rect,
NULL,
// While we don't seem to need RDW_NOERASE here for correctness
// (unlike Vista), I don't know whether it would hurt.
@@ -2390,7 +2392,7 @@ void XPFrame::ContinueDetachConstrainedWindowDrag(const gfx::Point& mouse_pt,
// correct. (Otherwise parts of the tabstrip are clipped).
CRect cr;
GetClientRect(&cr);
- PaintNow(cr);
+ PaintNow(gfx::Rect(cr));
// The user's mouse is already moving, and the left button is down, but we
// need to start moving this frame, so we _post_ it a NCLBUTTONDOWN message
diff --git a/chrome/browser/views/old_frames/xp_frame.h b/chrome/browser/views/old_frames/xp_frame.h
index 49a2c9f..c73b47d 100644
--- a/chrome/browser/views/old_frames/xp_frame.h
+++ b/chrome/browser/views/old_frames/xp_frame.h
@@ -160,7 +160,7 @@ class XPFrame : public BrowserWindow,
virtual void GetBounds(CRect *out, bool including_frame) const;
virtual void MoveToFront(bool should_activate);
virtual HWND GetHWND() const;
- virtual void PaintNow(const CRect& update_rect);
+ virtual void PaintNow(const gfx::Rect& update_rect);
virtual views::RootView* GetRootView();
virtual bool IsVisible();
virtual bool IsActive();
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc
index 6e1fbb1..54a8193 100644
--- a/chrome/browser/views/tabs/dragged_tab_view.cc
+++ b/chrome/browser/views/tabs/dragged_tab_view.cc
@@ -97,7 +97,7 @@ void DraggedTabView::Detach(HWNDPhotobooth* photobooth) {
void DraggedTabView::Update() {
container_->set_can_update_layered_window(true);
SchedulePaint();
- container_->PaintNow(CRect());
+ container_->PaintNow(gfx::Rect());
container_->set_can_update_layered_window(false);
}
diff --git a/chrome/views/container.h b/chrome/views/container.h
index e10b409..08f776c 100644
--- a/chrome/views/container.h
+++ b/chrome/views/container.h
@@ -8,6 +8,10 @@
// TODO(maruel): Remove once HWND is abstracted.
#include <windows.h>
+namespace gfx {
+class Rect;
+}
+
// TODO(maruel): Remove once gfx::Rect is used instead.
namespace WTL {
class CRect;
@@ -56,7 +60,7 @@ class Container {
virtual HWND GetHWND() const = 0;
// Forces a paint of a specified rectangle immediately.
- virtual void PaintNow(const CRect& update_rect) = 0;
+ virtual void PaintNow(const gfx::Rect& update_rect) = 0;
// Returns the RootView contained by this container
virtual RootView* GetRootView() = 0;
diff --git a/chrome/views/container_win.cc b/chrome/views/container_win.cc
index 7c0239d..59e1199 100644
--- a/chrome/views/container_win.cc
+++ b/chrome/views/container_win.cc
@@ -247,13 +247,13 @@ HWND ContainerWin::GetHWND() const {
return hwnd_;
}
-void ContainerWin::PaintNow(const CRect& update_rect) {
+void ContainerWin::PaintNow(const gfx::Rect& update_rect) {
if (layered_) {
PaintLayeredWindow();
} else if (root_view_->NeedsPainting(false) && IsWindow()) {
if (!opaque_ && GetParent()) {
// We're transparent. Need to force painting to occur from our parent.
- CRect parent_update_rect = update_rect;
+ CRect parent_update_rect = update_rect.ToRECT();
POINT location_in_parent = { 0, 0 };
ClientToScreen(hwnd_, &location_in_parent);
::ScreenToClient(GetParent(), &location_in_parent);
@@ -261,7 +261,8 @@ void ContainerWin::PaintNow(const CRect& update_rect) {
::RedrawWindow(GetParent(), parent_update_rect, NULL,
RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN);
} else {
- RedrawWindow(hwnd_, update_rect, NULL,
+ RECT native_update_rect = update_rect.ToRECT();
+ RedrawWindow(hwnd_, &native_update_rect, NULL,
RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
// As we were created with a style of WS_CLIPCHILDREN redraw requests may
@@ -805,7 +806,7 @@ void ContainerWin::ChangeSize(UINT size_param, const CSize& size) {
root_view_->SchedulePaint();
if (layered_)
- PaintNow(rect);
+ PaintNow(gfx::Rect(rect));
}
RootView* ContainerWin::CreateRootView() {
@@ -826,9 +827,9 @@ void ContainerWin::PaintLayeredWindow() {
// call to UpdateLayeredWindow updates the entire window, not just the
// cliprect.
contents_->save(SkCanvas::kClip_SaveFlag);
- CRect dirty_rect = root_view_->GetScheduledPaintRect();
- contents_->ClipRectInt(
- dirty_rect.left, dirty_rect.top, dirty_rect.Width(), dirty_rect.Height());
+ gfx::Rect dirty_rect = root_view_->GetScheduledPaintRect();
+ contents_->ClipRectInt(dirty_rect.x(), dirty_rect.y(), dirty_rect.width(),
+ dirty_rect.height());
root_view_->ProcessPaint(contents_.get());
contents_->restore();
diff --git a/chrome/views/container_win.h b/chrome/views/container_win.h
index 5df6529..a5f55f8 100644
--- a/chrome/views/container_win.h
+++ b/chrome/views/container_win.h
@@ -241,7 +241,7 @@ class ContainerWin : public Container,
virtual void GetBounds(CRect *out, bool including_frame) const;
virtual void MoveToFront(bool should_activate);
virtual HWND GetHWND() const;
- virtual void PaintNow(const CRect& update_rect);
+ virtual void PaintNow(const gfx::Rect& update_rect);
virtual RootView* GetRootView();
virtual bool IsVisible();
virtual bool IsActive();
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc
index f45731f..472a9bb 100644
--- a/chrome/views/custom_frame_window.cc
+++ b/chrome/views/custom_frame_window.cc
@@ -1157,7 +1157,7 @@ void CustomFrameWindow::OnNCPaint(HRGN rgn) {
UnionRect(&dirty_region, &tmp, &old_paint_region);
}
- root_view->SchedulePaint(dirty_region, false);
+ root_view->SchedulePaint(gfx::Rect(dirty_region), false);
// ChromeCanvasPaints destructor does the actual painting. As such, wrap the
// following in a block to force paint to occur so that we can release the dc.
diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc
index 80abe75..33597f9 100644
--- a/chrome/views/root_view.cc
+++ b/chrome/views/root_view.cc
@@ -53,7 +53,6 @@ const char RootView::kViewClassName[] = "chrome/views/RootView";
RootView::RootView(Container* container)
: container_(container),
- invalid_rect_(0,0,0,0),
mouse_pressed_handler_(NULL),
mouse_move_handler_(NULL),
explicit_mouse_handler_(FALSE),
@@ -91,14 +90,14 @@ RootView::~RootView() {
//
/////////////////////////////////////////////////////////////////////////////
-void RootView::SchedulePaint(const CRect& r, bool urgent) {
+void RootView::SchedulePaint(const gfx::Rect& r, bool urgent) {
// If there is an existing invalid rect, add the union of the scheduled
// rect with the invalid rect. This could be optimized further if
// necessary.
- if (invalid_rect_.IsRectNull())
+ if (invalid_rect_.IsEmpty())
invalid_rect_ = r;
else
- invalid_rect_.UnionRect(invalid_rect_, r);
+ invalid_rect_ = invalid_rect_.Union(r);
if (urgent || invalid_rect_urgent_) {
invalid_rect_urgent_ = true;
@@ -146,9 +145,9 @@ void RootView::ProcessPaint(ChromeCanvas* canvas) {
// Clip the invalid rect to our bounds. If a view is in a scrollview
// it could be a lot larger
- invalid_rect_ = GetScheduledPaintRectConstrainedToSize();
+ invalid_rect_ = gfx::Rect(GetScheduledPaintRectConstrainedToSize());
- if (invalid_rect_.IsRectNull())
+ if (invalid_rect_.IsEmpty())
return;
// Clear the background.
@@ -158,9 +157,10 @@ void RootView::ProcessPaint(ChromeCanvas* canvas) {
canvas->save();
// Set the clip rect according to the invalid rect.
- int clip_x = invalid_rect_.left + x();
- int clip_y = invalid_rect_.top + y();
- canvas->ClipRectInt(clip_x, clip_y, invalid_rect_.Width(), invalid_rect_.Height());
+ int clip_x = invalid_rect_.x() + x();
+ int clip_y = invalid_rect_.y() + y();
+ canvas->ClipRectInt(clip_x, clip_y, invalid_rect_.width(),
+ invalid_rect_.height());
// Paint the tree
View::ProcessPaint(canvas);
@@ -184,7 +184,7 @@ void RootView::PaintNow() {
}
bool RootView::NeedsPainting(bool urgent) {
- bool has_invalid_rect = !invalid_rect_.IsRectNull();
+ bool has_invalid_rect = !invalid_rect_.IsEmpty();
if (urgent) {
if (invalid_rect_urgent_)
return has_invalid_rect;
@@ -195,18 +195,15 @@ bool RootView::NeedsPainting(bool urgent) {
}
}
-const CRect& RootView::GetScheduledPaintRect() {
+const gfx::Rect& RootView::GetScheduledPaintRect() {
return invalid_rect_;
}
-CRect RootView::GetScheduledPaintRectConstrainedToSize() {
- if (invalid_rect_.IsRectEmpty())
- return invalid_rect_;
+RECT RootView::GetScheduledPaintRectConstrainedToSize() {
+ if (invalid_rect_.IsEmpty())
+ return invalid_rect_.ToRECT();
- CRect local_bounds = GetLocalBounds(true).ToRECT();
- CRect invalid_rect;
- invalid_rect.IntersectRect(&invalid_rect_, &local_bounds);
- return invalid_rect;
+ return invalid_rect_.Intersect(GetLocalBounds(true)).ToRECT();
}
/////////////////////////////////////////////////////////////////////////////
@@ -889,7 +886,7 @@ std::string RootView::GetClassName() const {
}
void RootView::ClearPaintRect() {
- invalid_rect_.SetRectEmpty();
+ invalid_rect_.SetRect(0, 0, 0, 0);
// This painting has been done. Reset the urgent flag.
invalid_rect_urgent_ = false;
@@ -899,9 +896,8 @@ void RootView::ClearPaintRect() {
}
void RootView::OnPaint(HWND hwnd) {
- CRect original_dirty_region =
- GetScheduledPaintRectConstrainedToSize();
- if (!original_dirty_region.IsRectEmpty()) {
+ RECT original_dirty_region = GetScheduledPaintRectConstrainedToSize();
+ if (!!IsRectEmpty(&original_dirty_region)) {
// Invoke InvalidateRect so that the dirty region of the window includes the
// region we need to paint. If we didn't do this and the region didn't
// include the dirty region, ProcessPaint would incorrectly mark everything
@@ -912,7 +908,7 @@ void RootView::OnPaint(HWND hwnd) {
ChromeCanvasPaint canvas(hwnd);
if (!canvas.isEmpty()) {
const PAINTSTRUCT& ps = canvas.paintStruct();
- SchedulePaint(ps.rcPaint, false);
+ SchedulePaint(gfx::Rect(ps.rcPaint), false);
if (NeedsPainting(false))
ProcessPaint(&canvas);
}
diff --git a/chrome/views/root_view.h b/chrome/views/root_view.h
index eef96eb..d15d354 100644
--- a/chrome/views/root_view.h
+++ b/chrome/views/root_view.h
@@ -51,7 +51,7 @@ class RootView : public View,
// Layout and Painting functions
// Overridden from View to implement paint scheduling.
- virtual void SchedulePaint(const CRect& r, bool urgent);
+ virtual void SchedulePaint(const gfx::Rect& r, bool urgent);
// Convenience to schedule the whole view
virtual void SchedulePaint();
@@ -73,10 +73,10 @@ class RootView : public View,
// Invoked by the Container to discover what rectangle should be
// painted
- const CRect& GetScheduledPaintRect();
+ const gfx::Rect& GetScheduledPaintRect();
// Returns the region scheduled to paint clipped to the RootViews bounds.
- CRect GetScheduledPaintRectConstrainedToSize();
+ RECT GetScheduledPaintRectConstrainedToSize();
// Tree functions
@@ -271,7 +271,7 @@ class RootView : public View,
Container* container_;
// The rectangle that should be painted
- CRect invalid_rect_;
+ gfx::Rect invalid_rect_;
// Whether the current invalid rect should be painted urgently.
bool invalid_rect_urgent_;
diff --git a/chrome/views/scroll_view.cc b/chrome/views/scroll_view.cc
index c6fdd7e..a440dd1 100644
--- a/chrome/views/scroll_view.cc
+++ b/chrome/views/scroll_view.cc
@@ -337,7 +337,7 @@ void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
else if (position > max_pos)
position = max_pos;
contents_->SetX(-position);
- contents_->SchedulePaint(contents_->GetLocalBounds(true).ToRECT(), true);
+ contents_->SchedulePaint(contents_->GetLocalBounds(true), true);
}
} else if (source == vert_sb_ && vert_sb_->IsVisible()) {
int vh = viewport_->height();
@@ -350,7 +350,7 @@ void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
else if (position > max_pos)
position = max_pos;
contents_->SetY(-position);
- contents_->SchedulePaint(contents_->GetLocalBounds(true).ToRECT(), true);
+ contents_->SchedulePaint(contents_->GetLocalBounds(true), true);
}
}
}
diff --git a/chrome/views/tooltip_manager.cc b/chrome/views/tooltip_manager.cc
index 6ddc31b..6da2245 100644
--- a/chrome/views/tooltip_manager.cc
+++ b/chrome/views/tooltip_manager.cc
@@ -190,7 +190,7 @@ LRESULT TooltipManager::OnNotify(int w_param, NMHDR* l_param, bool* handled) {
*handled = true;
tooltip_showing_ = true;
// The tooltip is about to show, allow the view to position it
- CPoint text_origin;
+ gfx::Point text_origin;
if (tooltip_height_ == 0)
tooltip_height_ = CalcTooltipHeight();
gfx::Point view_loc(last_mouse_x_, last_mouse_y_);
@@ -198,7 +198,7 @@ LRESULT TooltipManager::OnNotify(int w_param, NMHDR* l_param, bool* handled) {
last_tooltip_view_, &view_loc);
if (last_tooltip_view_->GetTooltipTextOrigin(
view_loc.x(), view_loc.y(), &text_origin) &&
- SetTooltipPosition(text_origin.x, text_origin.y)) {
+ SetTooltipPosition(text_origin.x(), text_origin.y())) {
// Return true, otherwise the rectangle we specified is ignored.
return TRUE;
}
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index 2b6c7cd..285aed7 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -159,9 +159,8 @@ gfx::Rect View::GetLocalBounds(bool include_border) const {
width() - insets.width(), height() - insets.height());
}
-void View::GetPosition(CPoint* p) const {
- p->x = GetX(APPLY_MIRRORING_TRANSFORMATION);
- p->y = y();
+gfx::Point View::GetPosition() const {
+ return gfx::Point(GetX(APPLY_MIRRORING_TRANSFORMATION), y());
}
gfx::Size View::GetPreferredSize() {
@@ -317,29 +316,25 @@ void View::SetHotTracked(bool flag) {
//
/////////////////////////////////////////////////////////////////////////////
-void View::SchedulePaint(const CRect& r, bool urgent) {
- if (!IsVisible()) {
+void View::SchedulePaint(const gfx::Rect& r, bool urgent) {
+ if (!IsVisible())
return;
- }
if (parent_) {
// Translate the requested paint rect to the parent's coordinate system
// then pass this notification up to the parent.
- CRect paint_rect(r);
- CPoint p;
- GetPosition(&p);
- paint_rect.OffsetRect(p);
+ gfx::Rect paint_rect = r;
+ paint_rect.Offset(GetPosition());
parent_->SchedulePaint(paint_rect, urgent);
}
}
void View::SchedulePaint() {
- SchedulePaint(GetLocalBounds(true).ToRECT(), false);
+ SchedulePaint(GetLocalBounds(true), false);
}
void View::SchedulePaint(int x, int y, int w, int h) {
- CRect r(x, y, x + w, y + h);
- SchedulePaint(&r, false);
+ SchedulePaint(gfx::Rect(x, y, w, h), false);
}
void View::Paint(ChromeCanvas* canvas) {
@@ -1506,7 +1501,7 @@ bool View::GetTooltipText(int x, int y, std::wstring* tooltip) {
return false;
}
-bool View::GetTooltipTextOrigin(int x, int y, CPoint* loc) {
+bool View::GetTooltipTextOrigin(int x, int y, gfx::Point* loc) {
return false;
}
diff --git a/chrome/views/view.h b/chrome/views/view.h
index b96e9ca..3df1c72 100644
--- a/chrome/views/view.h
+++ b/chrome/views/view.h
@@ -6,13 +6,9 @@
#define CHROME_VIEWS_VIEW_H_
#include <map>
+#include <oleacc.h>
#include <vector>
-// TODO(maruel): Remove these once WTL::CRect and WTL::CPoint are no more used.
-#include <atlbase.h>
-#include <atlapp.h>
-#include <atlmisc.h>
-
#include "base/gfx/rect.h"
#include "base/scoped_ptr.h"
#include "chrome/views/accelerator.h"
@@ -173,11 +169,12 @@ class View : public AcceleratorTarget {
// This is the function subclasses should use whenever they need to obtain
// the left position of one of their child views (for example, when
// implementing View::Layout()).
- int x() const {
- // This is equivalent to GetX(IGNORE_MIRRORING_TRANSFORMATION), but
- // inlinable.
- return bounds_.x();
- };
+ // This is equivalent to GetX(IGNORE_MIRRORING_TRANSFORMATION), but
+ // inlinable.
+ int x() const { return bounds_.x(); }
+ int y() const { return bounds_.y(); }
+ int width() const { return bounds_.width(); }
+ int height() const { return bounds_.height(); }
// Return the left coordinate of the View, relative to the parent. If
// |settings| is IGNORE_MIRRORING_SETTINGS, the function returns the value of
@@ -191,16 +188,6 @@ class View : public AcceleratorTarget {
// coordinate of a child View.
int GetX(PositionMirroringSettings settings) const;
- int y() const {
- return bounds_.y();
- };
- int width() const {
- return bounds_.width();
- };
- int height() const {
- return bounds_.height();
- };
-
// Return this control local bounds. If include_border is true, local bounds
// is the rectangle {0, 0, width(), height()}, otherwise, it does not
// include the area where the border (if any) is painted.
@@ -211,7 +198,7 @@ class View : public AcceleratorTarget {
// Note that if the parent uses right-to-left UI layout, then the mirrored
// position of this View is returned. Use x()/y() if you want to ignore
// mirroring.
- void GetPosition(CPoint* out) const;
+ gfx::Point GetPosition() const;
// Get the size the View would like to be, if enough space were available.
virtual gfx::Size GetPreferredSize();
@@ -364,7 +351,7 @@ class View : public AcceleratorTarget {
// Mark the specified rectangle as dirty (needing repaint). If |urgent| is
// true, the view will be repainted when the current event processing is
// done. Otherwise, painting will take place as soon as possible.
- virtual void SchedulePaint(const CRect& r, bool urgent);
+ virtual void SchedulePaint(const gfx::Rect& r, bool urgent);
// Mark the entire View's bounds as dirty. Painting will occur as soon as
// possible.
@@ -909,7 +896,7 @@ class View : public AcceleratorTarget {
// Returns the location (relative to this View) for the text on the tooltip
// to display. If false is returned (the default), the tooltip is placed at
// a default position.
- virtual bool GetTooltipTextOrigin(int x, int y, CPoint* loc);
+ virtual bool GetTooltipTextOrigin(int x, int y, gfx::Point* loc);
// Set whether this view is owned by its parent. A view that is owned by its
// parent is automatically deleted when the parent is deleted. The default is
@@ -1045,10 +1032,6 @@ class View : public AcceleratorTarget {
// window associated with them (so the root view gets the keyboard messages).
virtual void Focus();
- // Heavyweight views (views that hold a native control) should return the
- // window for that control.
- virtual HWND GetNativeControlHWND() { return NULL; }
-
// Invoked when a key is pressed before the key event is processed by the
// focus manager for accelerators. This gives a chance to the view to
// override an accelerator. Subclasser should return false if they want to