Commit 2a4e5617 authored by saintlou@chromium.org's avatar saintlou@chromium.org

Redo of Issue http://codereview.chromium.org/8621006/

Removed most obvious TOUCH_UI tests. Either obvious because we have USE_AURA | TOUCH_UI or because it is in a GTK module. 
This CL focuses mainly on Views cleanup. 

BUG=105046
TEST=none


Review URL: http://codereview.chromium.org/8632016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111204 0039d316-1c4b-4281-b951-d872f2087c98
parent 963b13d9
......@@ -42,16 +42,7 @@ class EventWaiter : public MessageLoopForUI::Observer {
virtual ~EventWaiter() {
MessageLoopForUI::current()->RemoveObserver(this);
}
#if defined(TOUCH_UI)
// MessageLoop::Observer implementation:
virtual base::EventStatus WillProcessEvent(const base::NativeEvent& event) {
NOTIMPLEMENTED();
return base::EVENT_CONTINUE;
}
virtual void DidProcessEvent(const base::NativeEvent& event) {
}
#else
// MessageLoop::Observer implementation:
virtual void WillProcessEvent(GdkEvent* event) {
if ((event->type == type_) && (--count_ == 0)) {
......@@ -69,7 +60,6 @@ class EventWaiter : public MessageLoopForUI::Observer {
virtual void DidProcessEvent(GdkEvent* event) {
// No-op.
}
#endif
private:
base::Closure task_;
......
......@@ -47,16 +47,6 @@ void BalloonCollectionImpl::PositionBalloons(bool reposition) {
PositionBalloonsInternal(reposition);
}
#if defined(TOUCH_UI)
base::EventStatus BalloonCollectionImpl::WillProcessEvent(
const base::NativeEvent& event) {
return base::EVENT_CONTINUE;
}
void BalloonCollectionImpl::DidProcessEvent(const base::NativeEvent& event) {
NOTIMPLEMENTED();
}
#else
void BalloonCollectionImpl::WillProcessEvent(GdkEvent* event) {
}
......@@ -70,7 +60,6 @@ void BalloonCollectionImpl::DidProcessEvent(GdkEvent* event) {
break;
}
}
#endif
bool BalloonCollectionImpl::IsCursorInBalloonCollection() const {
GdkScreen* screen = gdk_screen_get_default();
......
......@@ -16,9 +16,7 @@
#include "ui/base/gtk/gtk_compat.h"
#include "ui/base/gtk/gtk_hig_constants.h"
#if defined(TOUCH_UI)
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#elif defined(TOOLKIT_VIEWS)
#if defined(TOOLKIT_VIEWS)
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h"
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#else
......@@ -135,7 +133,7 @@ void ConstrainedWindowGtk::FocusConstrainedWindow() {
ConstrainedWindowGtk::TabContentsViewType*
ConstrainedWindowGtk::ContainingView() {
#if defined(TOOLKIT_VIEWS) && !defined(TOUCH_UI)
#if defined(TOOLKIT_VIEWS)
return static_cast<NativeTabContentsViewGtk*>(
static_cast<TabContentsViewViews*>(wrapper_->view())->
native_tab_contents_view());
......
......@@ -17,9 +17,7 @@
class TabContentsWrapper;
typedef struct _GdkColor GdkColor;
#if defined(TOUCH_UI)
class TabContentsViewViews;
#elif defined(TOOLKIT_VIEWS)
#if defined(TOOLKIT_VIEWS)
class NativeTabContentsViewGtk;
#else
class ChromeTabContentsViewWrapperGtk;
......@@ -51,9 +49,7 @@ class ConstrainedWindowGtkDelegate {
// centers the dialog. It is thus an order of magnitude simpler.
class ConstrainedWindowGtk : public ConstrainedWindow {
public:
#if defined(TOUCH_UI)
typedef TabContentsViewViews TabContentsViewType;
#elif defined(TOOLKIT_VIEWS)
#if defined(TOOLKIT_VIEWS)
typedef NativeTabContentsViewGtk TabContentsViewType;
#else
typedef ChromeTabContentsViewWrapperGtk TabContentsViewType;
......
......@@ -17,7 +17,7 @@
#include "chrome/browser/ui/gtk/task_manager_gtk.h"
#endif
#if !defined(OS_CHROMEOS) && !defined(TOUCH_UI)
#if !defined(OS_CHROMEOS)
#include "chrome/browser/ui/gtk/collected_cookies_gtk.h"
#include "chrome/browser/ui/gtk/repost_form_warning_gtk.h"
#endif
......
......@@ -11,10 +11,6 @@
#include "ui/views/widget/widget.h"
#include "views/controls/textfield/textfield.h"
#if defined(TOUCH_UI)
#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
#endif
void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos,
bool no_redraw) {
host_->SetBounds(new_pos);
......@@ -24,32 +20,5 @@ void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos,
NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent(
const TabContents* contents,
const views::KeyEvent& key_event) {
#if defined(TOUCH_UI)
// TODO(oshima): This is a copy from
// RenderWidgetHostViewViews::OnKeyPressed().
// Refactor and eliminate the dup code.
NativeWebKeyboardEvent wke;
wke.type = WebKit::WebInputEvent::KeyDown;
wke.windowsKeyCode = key_event.key_code();
wke.setKeyIdentifierFromWindowsKeyCode();
wke.text[0] = wke.unmodifiedText[0] =
static_cast<unsigned short>(gdk_keyval_to_unicode(
ui::GdkKeyCodeForWindowsKeyCode(key_event.key_code(),
key_event.IsShiftDown() ^ key_event.IsCapsLockDown())));
// Due to a bug in GDK, gdk_keyval_to_unicode(keyval) returns 0 if keyval
// is GDK_Return. It should instead return '\r'. This is causing
// http://code.google.com/p/chromium/issues/detail?id=75779
// Hence, the ugly hack below.
// TODO(varunjain): remove the hack when the GDK bug
// https://bugzilla.gnome.org/show_bug.cgi?id=644836 gets sorted out.
if (key_event.key_code() == ui::VKEY_RETURN) {
wke.text[0] = wke.unmodifiedText[0] = '\r';
}
return wke;
#else
return NativeWebKeyboardEvent(key_event.gdk_event());
#endif
}
......@@ -6,13 +6,6 @@
'variables': {
'chromium_code': 1,
},
'target_defaults': {
'conditions': [
['touchui==0', {'sources/': [
['exclude', '_(touch)\\.cc$'],
]}],
],
},
'includes': [
'ui_resources.gypi',
],
......
......@@ -14,12 +14,7 @@ namespace views {
MenuConfig* MenuConfig::Create() {
MenuConfig* config = new MenuConfig();
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
#if defined(TOUCH_UI)
config->font = rb.GetFont(ResourceBundle::LargeFont);
config->show_accelerators = false;
#else
config->font = rb.GetFont(ResourceBundle::BaseFont);
#endif
config->arrow_width = rb.GetBitmapNamed(IDR_MENU_ARROW)->width();
// Add 4 to force some padding between check and label.
config->check_width = rb.GetBitmapNamed(IDR_MENU_CHECK)->width() + 4;
......
......@@ -14,12 +14,7 @@ namespace views {
MenuConfig* MenuConfig::Create() {
MenuConfig* config = new MenuConfig();
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
#if defined(TOUCH_UI)
config->font = rb.GetFont(ResourceBundle::LargeFont);
config->show_accelerators = false;
#else
config->font = rb.GetFont(ResourceBundle::BaseFont);
#endif
config->arrow_width = rb.GetBitmapNamed(IDR_MENU_ARROW)->width();
// Add 4 to force some padding between check and label.
config->check_width = rb.GetBitmapNamed(IDR_MENU_CHECK)->width() + 4;
......
......@@ -223,7 +223,7 @@ class VIEWS_EXPORT MenuController : public MessageLoop::Dispatcher {
#elif defined(USE_WAYLAND)
virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(
base::wayland::WaylandEvent* event);
#elif defined(TOUCH_UI) || defined(USE_AURA)
#elif defined(USE_AURA)
virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xevent);
#else
virtual bool Dispatch(GdkEvent* event);
......
......@@ -48,9 +48,6 @@ void MenuHost::ShowMenuHost(bool do_capture) {
// process of showing.
ignore_capture_lost_ = true;
Show();
#if defined(TOUCH_UI)
Activate();
#endif
if (do_capture)
native_widget_private()->SetMouseCapture();
ignore_capture_lost_ = false;
......
......@@ -54,10 +54,6 @@ class EmptyMenuMenuItem : public MenuItemView {
// Padding between child views.
static const int kChildXPadding = 8;
#if defined(TOUCH_UI)
const int kMinItemHeightTouch = 40;
#endif
// MenuItemView ---------------------------------------------------------------
// static
......@@ -750,11 +746,7 @@ gfx::Size MenuItemView::CalculatePreferredSize() {
}
const gfx::Font& font = GetFont();
#if defined(TOUCH_UI)
int height = std::max(font.GetHeight(), kMinItemHeightTouch);
#else
int height = font.GetHeight();
#endif
return gfx::Size(
font.GetStringWidth(title_) + label_start_ +
item_right_margin_ + child_size.width(),
......
......@@ -4,10 +4,6 @@
#include "views/controls/menu/nested_dispatcher_gtk.h"
#if defined(TOUCH_UI)
#include "ui/views/focus/accelerator_handler.h"
#endif
namespace views {
NestedDispatcherGtk::NestedDispatcherGtk(MessageLoopForUI::Dispatcher* creator,
......@@ -32,15 +28,8 @@ void NestedDispatcherGtk::CreatorDestroyed() {
creator_ = NULL;
}
#if defined(TOUCH_UI)
base::MessagePumpDispatcher::DispatchStatus
NestedDispatcherGtk::Dispatch(XEvent* xevent) {
return creator_->Dispatch(xevent);
}
#else
bool NestedDispatcherGtk::Dispatch(GdkEvent* event) {
return creator_ && creator_->Dispatch(event);
}
#endif // defined(TOUCH_UI)
} // namespace views
......@@ -8,10 +8,6 @@
#include "base/message_loop.h"
#if defined(TOUCH_UI)
typedef union _XEvent XEvent;
#endif
namespace views {
// A nested dispatcher that can out-live the creator of this
......@@ -37,12 +33,8 @@ class NestedDispatcherGtk : public MessageLoopForUI::Dispatcher {
private:
virtual ~NestedDispatcherGtk() {}
#if defined(TOUCH_UI)
virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xevent);
#else
// Overriden from MessageLoopForUI::Dispatcher:
virtual bool Dispatch(GdkEvent* event);
#endif
// Creator of the nested loop.
MessageLoopForUI::Dispatcher* creator_;
......
......@@ -11,135 +11,8 @@
#include "ui/views/focus/focus_manager.h"
#include "ui/views/widget/widget.h"
#if defined(TOUCH_UI)
namespace {
GdkEvent* MouseButtonEvent(const views::MouseEvent& mouseev,
const views::NativeViewHost* source) {
GdkEvent* event = NULL;
switch (mouseev.type()) {
case ui::ET_MOUSE_PRESSED:
event = gdk_event_new(GDK_BUTTON_PRESS);
break;
case ui::ET_MOUSE_RELEASED:
event = gdk_event_new(GDK_BUTTON_RELEASE);
break;
default:
NOTREACHED();
return NULL;
}
event->button.send_event = false;
event->button.time = GDK_CURRENT_TIME;
// Ideally using native_view()->window should work, but it doesn't.
event->button.window = gdk_window_at_pointer(NULL, NULL);
g_object_ref(event->button.window);
event->button.x = mouseev.location().x();
event->button.y = mouseev.location().y();
gfx::Point point = mouseev.location();
views::View::ConvertPointToScreen(source, &point);
event->button.x_root = point.x();
event->button.y_root = point.y();
event->button.axes = NULL;
// Ideally, this should reconstruct the state from mouseev.flags().
GdkModifierType modifier;
gdk_window_get_pointer(event->button.window, NULL, NULL, &modifier);
event->button.state = modifier;
event->button.button = (mouseev.flags() & ui::EF_LEFT_BUTTON_DOWN) ? 1 :
(mouseev.flags() & ui::EF_RIGHT_BUTTON_DOWN) ? 3 :
2;
event->button.device = gdk_device_get_core_pointer();
return event;
}
GdkEvent* MouseMoveEvent(const views::MouseEvent& mouseev,
const views::NativeViewHost* source) {
GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY);
event->motion.send_event = false;
event->motion.time = GDK_CURRENT_TIME;
event->motion.window = source->native_view()->window;
g_object_ref(event->motion.window);
event->motion.x = mouseev.location().x();
event->motion.y = mouseev.location().y();
gfx::Point point = mouseev.location();
views::View::ConvertPointToScreen(source, &point);
event->motion.x_root = point.x();
event->motion.y_root = point.y();
event->motion.device = gdk_device_get_core_pointer();
return event;
}
GdkEvent* MouseCrossEvent(const views::MouseEvent& mouseev,
const views::NativeViewHost* source) {
GdkEvent* event = NULL;
switch (mouseev.type()) {
case ui::ET_MOUSE_ENTERED:
event = gdk_event_new(GDK_ENTER_NOTIFY);
break;
case ui::ET_MOUSE_EXITED:
event = gdk_event_new(GDK_LEAVE_NOTIFY);
break;
default:
NOTREACHED();
return NULL;
}
event->crossing.send_event = false;
event->crossing.time = GDK_CURRENT_TIME;
event->crossing.window = source->native_view()->window;
g_object_ref(event->crossing.window);
event->crossing.x = event->crossing.y = 0;
event->crossing.x_root = event->crossing.y_root = 0;
event->crossing.mode = GDK_CROSSING_NORMAL;
event->crossing.detail = GDK_NOTIFY_VIRTUAL;
event->crossing.focus = false;
event->crossing.state = 0;
return event;
}
} // namespace
#endif // defined(TOUCH_UI)
namespace views {
#if defined(TOUCH_UI)
void NativeControlGtk::FakeNativeMouseEvent(const MouseEvent& mouseev) {
GdkEvent* event = NULL;
switch (mouseev.type()) {
case ui::ET_MOUSE_PRESSED:
case ui::ET_MOUSE_RELEASED:
event = MouseButtonEvent(mouseev, this);
break;
case ui::ET_MOUSE_MOVED:
event = MouseMoveEvent(mouseev, this);
break;
case ui::ET_MOUSE_ENTERED:
case ui::ET_MOUSE_EXITED:
event = MouseCrossEvent(mouseev, this);
break;
default:
NOTREACHED();
return;
}
if (event) {
// Do not gdk_event_put, since that will end up going through the
// message-loop and turn into an infinite loop.
gtk_widget_event(native_view(), event);
gdk_event_free(event);
}
}
#endif // defined(TOUCH_UI)
NativeControlGtk::NativeControlGtk() {
}
......@@ -189,29 +62,6 @@ void NativeControlGtk::OnFocus() {
parent(), ui::AccessibilityTypes::EVENT_FOCUS, true);
}
#if defined(TOUCH_UI)
bool NativeControlGtk::OnMousePressed(const MouseEvent& mouseev) {
FakeNativeMouseEvent(mouseev);
return true;
}
void NativeControlGtk::OnMouseReleased(const MouseEvent& mouseev) {
FakeNativeMouseEvent(mouseev);
}
void NativeControlGtk::OnMouseMoved(const MouseEvent& mouseev) {
FakeNativeMouseEvent(mouseev);
}
void NativeControlGtk::OnMouseEntered(const MouseEvent& mouseev) {
FakeNativeMouseEvent(mouseev);
}
void NativeControlGtk::OnMouseExited(const MouseEvent& mouseev) {
FakeNativeMouseEvent(mouseev);
}
#endif // defined(TOUCH_UI)
void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) {
Attach(native_control);
......
......@@ -25,16 +25,6 @@ class NativeControlGtk : public NativeViewHost {
virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);
virtual void VisibilityChanged(View* starting_from, bool is_visible);
virtual void OnFocus();
#if defined(TOUCH_UI)
virtual bool OnMousePressed(const MouseEvent& event);
virtual void OnMouseReleased(const MouseEvent& event);
virtual void OnMouseMoved(const MouseEvent& event);
virtual void OnMouseExited(const MouseEvent& event);
virtual void OnMouseEntered(const MouseEvent& event);
// Fake a mouse event.
void FakeNativeMouseEvent(const MouseEvent& event);
#endif
// Called when the NativeControlGtk is attached to a View hierarchy with a
// valid Widget. The NativeControlGtk should use this opportunity to create
......
......@@ -797,7 +797,6 @@ TEST_F(NativeTextfieldViewsTest, DragAndDrop_AcceptDrop) {
}
#endif
#if !defined(TOUCH_UI)
TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_InitiateDrag) {
InitTextfield(Textfield::STYLE_DEFAULT);
textfield_->SetText(ASCIIToUTF16("hello string world"));
......@@ -969,7 +968,6 @@ TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_Canceled) {
textfield_view_->OnDragDone();
EXPECT_EQ(ASCIIToUTF16("hello world"), textfield_->text());
}
#endif
TEST_F(NativeTextfieldViewsTest, ReadOnlyTest) {
InitTextfield(Textfield::STYLE_DEFAULT);
......
......@@ -77,7 +77,7 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer {
}
return EVENT_CONTINUE;
}
#elif defined(TOUCH_UI) || defined(USE_AURA)
#elif defined(USE_AURA)
virtual base::EventStatus WillProcessEvent(
const base::NativeEvent& event) OVERRIDE {
return base::EVENT_CONTINUE;
......
......@@ -13,11 +13,6 @@
['include', '/win/'],
['include', '/win_[^/]*\\.cc$'],
]}],
['touchui==0', {
'sources/': [
['exclude', '_(touch)\\.cc$'],
],
}],
['use_aura==1', {
'sources/': [ ['exclude', '_win\\.(h|cc)$'],
['exclude', '_gtk\\.(h|cc)$'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment