summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-03 15:47:07 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-03 15:47:07 +0000
commit61ede748570cf4495bba507a57f47cc6a664a1e1 (patch)
tree52c729c2156839d64091259ed36779e502ec6aea /ui
parent35f929c7e1cd451c3077d8bd8e2fc31b6e2eb50f (diff)
downloadchromium_src-61ede748570cf4495bba507a57f47cc6a664a1e1.zip
chromium_src-61ede748570cf4495bba507a57f47cc6a664a1e1.tar.gz
chromium_src-61ede748570cf4495bba507a57f47cc6a664a1e1.tar.bz2
Allow Window point conversion with a NULL source. This just returns immediately without modifying the supplied point. This fixes a crash when converting points for an unparented RWHVA, since the code passes parent_ as source and parent_ is NULL.
Had to remove some export stuff from tests to make this build in component build. test_support_base is a static library, thus need not have AURA_EXPORT. BUG=none TEST=none Review URL: http://codereview.chromium.org/8438052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/test/aura_test_base.h3
-rw-r--r--ui/aura/test/event_generator.h3
-rw-r--r--ui/aura/test/test_desktop_delegate.h3
-rw-r--r--ui/aura/window.cc2
-rw-r--r--ui/aura/window.h3
-rw-r--r--ui/aura/window_unittest.cc11
6 files changed, 19 insertions, 6 deletions
diff --git a/ui/aura/test/aura_test_base.h b/ui/aura/test/aura_test_base.h
index 6f8c829..6c9d3ff 100644
--- a/ui/aura/test/aura_test_base.h
+++ b/ui/aura/test/aura_test_base.h
@@ -6,7 +6,6 @@
#define UI_AURA_TEST_AURA_TEST_BASE_H_
#pragma once
-#include "ui/aura/aura_export.h"
#include "base/compiler_specific.h"
#include "base/basictypes.h"
#include "base/message_loop.h"
@@ -18,7 +17,7 @@ namespace test {
class TestDesktopDelegate;
// A base class for aura unit tests.
-class AURA_EXPORT AuraTestBase : public testing::Test {
+class AuraTestBase : public testing::Test {
public:
AuraTestBase();
virtual ~AuraTestBase();
diff --git a/ui/aura/test/event_generator.h b/ui/aura/test/event_generator.h
index a50c2ef..f375f9d 100644
--- a/ui/aura/test/event_generator.h
+++ b/ui/aura/test/event_generator.h
@@ -6,7 +6,6 @@
#define UI_AURA_TEST_EVENT_GENERATOR_H_
#pragma once
-#include "ui/aura/aura_export.h"
#include "base/basictypes.h"
#include "ui/gfx/point.h"
@@ -18,7 +17,7 @@ namespace test {
// EventGenerator is a tool that generates and dispatch events.
// TODO(oshima): Support key events.
-class AURA_EXPORT EventGenerator {
+class EventGenerator {
public:
// Creates an EventGenerator with the mouse location (0,0).
EventGenerator();
diff --git a/ui/aura/test/test_desktop_delegate.h b/ui/aura/test/test_desktop_delegate.h
index 2be7fe9..09bfc31e 100644
--- a/ui/aura/test/test_desktop_delegate.h
+++ b/ui/aura/test/test_desktop_delegate.h
@@ -6,7 +6,6 @@
#define UI_AURA_TEST_TEST_DESKTOP_DELEGATE_H_
#pragma once
-#include "ui/aura/aura_export.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
@@ -18,7 +17,7 @@ class ToplevelWindowContainer;
namespace test {
-class AURA_EXPORT TestDesktopDelegate : public DesktopDelegate {
+class TestDesktopDelegate : public DesktopDelegate {
public:
// Callers should allocate a TestDesktopDelegate on the heap and then forget
// about it -- the c'tor passes ownership of the TestDesktopDelegate to the
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index f7291f2..025e936 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -261,6 +261,8 @@ const Window* Window::GetChildById(int id) const {
void Window::ConvertPointToWindow(const Window* source,
const Window* target,
gfx::Point* point) {
+ if (!source)
+ return;
ui::Layer::ConvertPointToLayer(source->layer(), target->layer(), point);
}
diff --git a/ui/aura/window.h b/ui/aura/window.h
index b376914..bab696d 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -179,6 +179,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate {
Window* GetChildById(int id);
const Window* GetChildById(int id) const;
+ // Converts |point| from |source|'s coordinates to |target|'s. If |source| is
+ // NULL, the function returns without modifying |point|. |target| cannot be
+ // NULL.
static void ConvertPointToWindow(const Window* source,
const Window* target,
gfx::Point* point);
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index 1db4206..c57171c 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -203,6 +203,17 @@ TEST_F(WindowTest, GetChildById) {
EXPECT_EQ(w111.get(), w1->GetChildById(111));
}
+TEST_F(WindowTest, ConvertPointToWindow) {
+ // Window::ConvertPointToWindow is mostly identical to
+ // Layer::ConvertPointToLayer, except NULL values for |source| are permitted,
+ // in which case the function just returns.
+ scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
+ gfx::Point reference_point(100, 100);
+ gfx::Point test_point = reference_point;
+ Window::ConvertPointToWindow(NULL, w1.get(), &test_point);
+ EXPECT_EQ(reference_point, test_point);
+}
+
TEST_F(WindowTest, HitTest) {
Window w1(new ColorTestWindowDelegate(SK_ColorWHITE));
w1.set_id(1);