Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: ui/ozone/platform/dri/dri_cursor.cc

Issue 556073003: [Ozone-DRI] Do proper bounds checks when moving the cursor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@restore-cursor
Patch Set: . Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/dri/dri_cursor.h ('k') | ui/ozone/platform/dri/dri_surface_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/dri/dri_cursor.cc
diff --git a/ui/ozone/platform/dri/dri_cursor.cc b/ui/ozone/platform/dri/dri_cursor.cc
index a6fe5fe0f71f8f8091cf1f1788d30410430df571..7d97f4fc4ab161df1269181f0afdb288b9be447e 100644
--- a/ui/ozone/platform/dri/dri_cursor.cc
+++ b/ui/ozone/platform/dri/dri_cursor.cc
@@ -9,15 +9,17 @@
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/ozone/platform/dri/dri_surface_factory.h"
+#include "ui/ozone/platform/dri/dri_window.h"
+#include "ui/ozone/platform/dri/dri_window_manager.h"
#include "ui/ozone/platform/dri/hardware_cursor_delegate.h"
namespace ui {
-DriCursor::DriCursor(HardwareCursorDelegate* hardware) : hardware_(hardware) {
- // TODO(dnicoara) Assume the first widget since at this point there are no
- // widgets initialized.
- cursor_window_ = DriSurfaceFactory::kDefaultWidgetHandle;
- cursor_location_ = gfx::PointF(2560 / 2, 1700 / 2); // TODO(spang): Argh!
+DriCursor::DriCursor(HardwareCursorDelegate* hardware,
+ DriWindowManager* window_manager)
+ : hardware_(hardware),
+ window_manager_(window_manager),
+ cursor_window_(DriSurfaceFactory::kDefaultWidgetHandle) {
}
DriCursor::~DriCursor() {
@@ -25,6 +27,7 @@ DriCursor::~DriCursor() {
void DriCursor::SetCursor(gfx::AcceleratedWidget widget,
PlatformCursor platform_cursor) {
+ DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
scoped_refptr<BitmapCursorOzone> cursor =
BitmapCursorFactoryOzone::GetBitmapCursor(platform_cursor);
if (cursor_ == cursor || cursor_window_ != widget)
@@ -35,6 +38,7 @@ void DriCursor::SetCursor(gfx::AcceleratedWidget widget,
}
void DriCursor::ShowCursor() {
+ DCHECK_NE(cursor_window_, gfx::kNullAcceleratedWidget);
if (cursor_.get())
hardware_->SetHardwareCursor(cursor_window_,
cursor_->bitmaps(),
@@ -45,19 +49,24 @@ void DriCursor::ShowCursor() {
}
void DriCursor::HideCursor() {
+ DCHECK_NE(cursor_window_, gfx::kNullAcceleratedWidget);
hardware_->SetHardwareCursor(
cursor_window_, std::vector<SkBitmap>(), gfx::Point(), 0);
}
void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) {
- if (widget != cursor_window_)
+ if (widget != cursor_window_ && cursor_window_ != gfx::kNullAcceleratedWidget)
HideCursor();
cursor_window_ = widget;
cursor_location_ = location;
- gfx::Size size = gfx::Size(2560, 1700); // TODO(spang): Fix.
+ DriWindow* window = window_manager_->GetWindow(widget);
+ if (cursor_window_ == gfx::kNullAcceleratedWidget || !window)
spang 2014/09/15 18:23:34 Shouldn't this just be if (!window)
+ return;
+
+ const gfx::Size& size = window->GetBounds().size();
cursor_location_.SetToMax(gfx::PointF(0, 0));
cursor_location_.SetToMin(gfx::PointF(size.width(), size.height()));
« no previous file with comments | « ui/ozone/platform/dri/dri_cursor.h ('k') | ui/ozone/platform/dri/dri_surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698