summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-13 00:12:52 +0000
committeroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-13 00:12:52 +0000
commit5ad65b545d9f0b465e41a19bce5c15e6c0d0027a (patch)
tree0b935d520d8e644d29910550db03a6152a55cd82
parent43129860c569ddf6176858e2e010645bbadaf554 (diff)
downloadchromium_src-5ad65b545d9f0b465e41a19bce5c15e6c0d0027a.zip
chromium_src-5ad65b545d9f0b465e41a19bce5c15e6c0d0027a.tar.gz
chromium_src-5ad65b545d9f0b465e41a19bce5c15e6c0d0027a.tar.bz2
Revert 100792 "Use TabContentsViewViews for RenderWidgetHostViweViews."
This reverts commit a8938434c75e2a7300e04c1f23fe363bdcb67bc6. BUG=none TEST=none Review URL: http://codereview.chromium.org/7878008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100812 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_content_browser_client.cc8
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views.cc5
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views.h8
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_views_gtk.cc29
-rw-r--r--chrome/browser/ui/gtk/constrained_window_gtk.cc2
-rw-r--r--chrome/browser/ui/gtk/constrained_window_gtk.h4
-rw-r--r--chrome/browser/ui/touch/keyboard/keyboard_manager.cc2
-rw-r--r--chrome/browser/ui/views/dom_view.cc20
-rw-r--r--chrome/browser/ui/views/find_bar_host_gtk.cc10
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc8
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_container_views.cc9
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc4
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc4
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.cc35
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.h9
-rw-r--r--chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc16
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_container.h9
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_container_native.cc46
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_container_native.h3
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_touch.cc430
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h160
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc25
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_views.h6
-rw-r--r--chrome/chrome_browser.gypi13
-rw-r--r--views/controls/button/menu_button.cc4
-rw-r--r--views/widget/native_widget_gtk.cc28
-rw-r--r--views/widget/native_widget_gtk.h1
-rw-r--r--views/widget/native_widget_private.h1
-rw-r--r--views/widget/native_widget_view.cc51
-rw-r--r--views/widget/native_widget_views.cc79
-rw-r--r--views/widget/native_widget_views.h12
-rw-r--r--views/widget/native_widget_win.cc4
-rw-r--r--views/widget/native_widget_win.h1
-rw-r--r--views/widget/widget.cc6
-rw-r--r--views/widget/widget.h3
35 files changed, 769 insertions, 286 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 5a42dde..1df60b6 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -76,7 +76,9 @@
#include "chrome/browser/crash_handler_host_linux.h"
#endif
-#if defined(TOOLKIT_VIEWS)
+#if defined(TOUCH_UI)
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
+#elif defined(TOOLKIT_VIEWS)
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#elif defined(OS_LINUX)
#include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
@@ -135,7 +137,9 @@ content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
TabContentsView* ChromeContentBrowserClient::CreateTabContentsView(
TabContents* tab_contents) {
-#if defined(TOOLKIT_VIEWS)
+#if defined(TOUCH_UI)
+ return new TabContentsViewTouch(tab_contents);
+#elif defined(TOOLKIT_VIEWS)
return new TabContentsViewViews(tab_contents);
#elif defined(OS_LINUX)
return new TabContentsViewGtk(tab_contents);
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc
index 2fac61d..6396c4b 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc
@@ -194,8 +194,7 @@ void RenderWidgetHostViewViews::SetSize(const gfx::Size& size) {
}
void RenderWidgetHostViewViews::SetBounds(const gfx::Rect& rect) {
- // TODO(oshima): chromeos/touch doesn't allow moving window.
- SetSize(rect.size());
+ NOTIMPLEMENTED();
}
gfx::NativeView RenderWidgetHostViewViews::GetNativeView() const {
@@ -749,7 +748,7 @@ void RenderWidgetHostViewViews::OnPaint(gfx::Canvas* canvas) {
// Only render the widget if it is attached to a window; there's a short
// period where this object isn't attached to a window but hasn't been
// Destroy()ed yet and it receives paint messages...
- if (IsReadyToPaint()) {
+ if (GetInnerNativeView()->window) {
#endif
if (!visually_deemphasized_) {
// In the common case, use XCopyArea. We don't draw more than once, so
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.h b/chrome/browser/renderer_host/render_widget_host_view_views.h
index 6c7b8a9..e81b48d 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.h
@@ -174,7 +174,7 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
#endif
protected:
- // Overridden from views::View.
+ // Overridden views::View.
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void OnFocus() OVERRIDE;
virtual void OnBlur() OVERRIDE;
@@ -210,8 +210,10 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
void UpdateTouchSelectionController();
#if defined(TOOLKIT_USES_GTK)
- // Returns true if the RWHV is ready to paint the content.
- bool IsReadyToPaint();
+ // On some systems, there can be two native views, where an outer native view
+ // contains the inner native view (e.g. when using GTK+). This returns the
+ // inner view. This can return NULL when it's not attached to a view.
+ gfx::NativeView GetInnerNativeView() const;
#endif
// The model object.
diff --git a/chrome/browser/renderer_host/render_widget_host_view_views_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_views_gtk.cc
index f253314..e8437a7 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views_gtk.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_views_gtk.cc
@@ -69,26 +69,25 @@ gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
}
#endif
-bool RenderWidgetHostViewViews::IsReadyToPaint() {
- views::Widget* top = NULL;
- // TODO(oshima): move this functionality to Widget.
- if (views::ViewsDelegate::views_delegate &&
- views::ViewsDelegate::views_delegate->GetDefaultParentView()) {
- top = views::ViewsDelegate::views_delegate->GetDefaultParentView()->
- GetWidget();
- } else {
- top = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
- }
-
- return top ?
- !!(static_cast<const views::NativeWidgetGtk*>(top->native_widget())->
- window_contents()->window) : false;
+gfx::NativeView RenderWidgetHostViewViews::GetInnerNativeView() const {
+ const views::View* view = NULL;
+ if (views::ViewsDelegate::views_delegate)
+ view = views::ViewsDelegate::views_delegate->GetDefaultParentView();
+ if (!view)
+ view = this;
+
+ // TODO(sad): Ideally this function should be equivalent to GetNativeView, and
+ // NativeWidgetGtk-specific function call should not be necessary.
+ const views::Widget* widget = view->GetWidget();
+ const views::NativeWidget* native = widget ? widget->native_widget() : NULL;
+ return native ? static_cast<const views::NativeWidgetGtk*>(native)->
+ window_contents() : NULL;
}
void RenderWidgetHostViewViews::ShowCurrentCursor() {
// The widget may not have a window. If that's the case, abort mission. This
// is the same issue as that explained above in Paint().
- if (!IsReadyToPaint())
+ if (!GetInnerNativeView() || !GetInnerNativeView()->window)
return;
native_cursor_ = current_cursor_.GetNativeCursor();
diff --git a/chrome/browser/ui/gtk/constrained_window_gtk.cc b/chrome/browser/ui/gtk/constrained_window_gtk.cc
index 01cc99b..f2026a8 100644
--- a/chrome/browser/ui/gtk/constrained_window_gtk.cc
+++ b/chrome/browser/ui/gtk/constrained_window_gtk.cc
@@ -13,7 +13,7 @@
#include "ui/base/gtk/gtk_hig_constants.h"
#if defined(TOUCH_UI)
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
#elif 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"
diff --git a/chrome/browser/ui/gtk/constrained_window_gtk.h b/chrome/browser/ui/gtk/constrained_window_gtk.h
index 2b7b4c1..25a9912 100644
--- a/chrome/browser/ui/gtk/constrained_window_gtk.h
+++ b/chrome/browser/ui/gtk/constrained_window_gtk.h
@@ -17,7 +17,7 @@
class TabContents;
typedef struct _GdkColor GdkColor;
#if defined(TOUCH_UI)
-class TabContentsViewViews;
+class TabContentsViewTouch;
#elif defined(TOOLKIT_VIEWS)
class NativeTabContentsViewGtk;
#else
@@ -51,7 +51,7 @@ class ConstrainedWindowGtkDelegate {
class ConstrainedWindowGtk : public ConstrainedWindow {
public:
#if defined(TOUCH_UI)
- typedef TabContentsViewViews TabContentsViewType;
+ typedef TabContentsViewTouch TabContentsViewType;
#elif defined(TOOLKIT_VIEWS)
typedef NativeTabContentsViewGtk TabContentsViewType;
#else
diff --git a/chrome/browser/ui/touch/keyboard/keyboard_manager.cc b/chrome/browser/ui/touch/keyboard/keyboard_manager.cc
index bb9f85c..97f78a9 100644
--- a/chrome/browser/ui/touch/keyboard/keyboard_manager.cc
+++ b/chrome/browser/ui/touch/keyboard/keyboard_manager.cc
@@ -13,10 +13,12 @@
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/views/dom_view.h"
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/url_constants.h"
#include "content/browser/site_instance.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_observer.h"
#include "content/common/notification_service.h"
#include "ui/base/animation/animation_delegate.h"
diff --git a/chrome/browser/ui/views/dom_view.cc b/chrome/browser/ui/views/dom_view.cc
index 6f90426..4555bd1 100644
--- a/chrome/browser/ui/views/dom_view.cc
+++ b/chrome/browser/ui/views/dom_view.cc
@@ -6,10 +6,12 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_preferences_util.h"
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "views/focus/focus_manager.h"
-#include "views/widget/native_widget_views.h"
+
+#if defined(TOUCH_UI)
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
+#endif
// static
const char DOMView::kViewClassName[] =
@@ -79,13 +81,9 @@ void DOMView::ViewHierarchyChanged(bool is_add, views::View* parent,
}
void DOMView::AttachTabContents() {
- if (views::Widget::IsPureViews()) {
- TabContentsViewViews* widget =
- static_cast<TabContentsViewViews*>(tab_contents_->view());
- views::NativeWidgetViews* nwv =
- static_cast<views::NativeWidgetViews*>(widget->native_widget());
- AttachToView(nwv->GetView());
- } else {
- Attach(tab_contents_->GetNativeView());
- }
+#if defined(TOUCH_UI)
+ AttachToView(static_cast<TabContentsViewTouch*>(tab_contents_->view()));
+#else
+ Attach(tab_contents_->GetNativeView());
+#endif
}
diff --git a/chrome/browser/ui/views/find_bar_host_gtk.cc b/chrome/browser/ui/views/find_bar_host_gtk.cc
index ca516d6..1600e34 100644
--- a/chrome/browser/ui/views/find_bar_host_gtk.cc
+++ b/chrome/browser/ui/views/find_bar_host_gtk.cc
@@ -7,10 +7,13 @@
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
+#if defined(TOUCH_UI)
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
+#endif
+
void FindBarHost::AudibleAlert() {
// TODO(davemoore) implement.
NOTIMPLEMENTED();
@@ -20,7 +23,12 @@ void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) {
gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowScreenBounds();
TabContentsView* tab_view = find_bar_controller_->tab_contents()->view();
gfx::Rect webcontents_rect;
+#if defined(TOUCH_UI)
+ webcontents_rect =
+ static_cast<TabContentsViewTouch*>(tab_view)->GetScreenBounds();
+#else
tab_view->GetViewBounds(&webcontents_rect);
+#endif
avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y());
}
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc
index 7705344..e836183 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc
@@ -13,6 +13,7 @@
#include "content/browser/tab_contents/tab_contents.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "views/focus/focus_manager.h"
+#include "views/views_delegate.h"
////////////////////////////////////////////////////////////////////////////////
// NativeTabContentsContainerGtk, public:
@@ -62,6 +63,7 @@ views::View* NativeTabContentsContainerGtk::GetView() {
void NativeTabContentsContainerGtk::TabContentsFocused(
TabContents* tab_contents) {
+#if !defined(TOUCH_UI)
// Called when the tab contents native view gets focused (typically through a
// user click). We make ourself the focused view, so the focus is restored
// properly when the browser window is deactivated/reactivated.
@@ -71,6 +73,9 @@ void NativeTabContentsContainerGtk::TabContentsFocused(
return;
}
focus_manager->SetFocusedView(this);
+#else
+ // no native views in TOUCH_UI, so don't steal the focus
+#endif
}
////////////////////////////////////////////////////////////////////////////////
@@ -142,7 +147,8 @@ void NativeTabContentsContainerGtk::GetAccessibleState(
// static
NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer(
TabContentsContainer* container) {
- if (views::Widget::IsPureViews())
+ if (views::Widget::IsPureViews() &&
+ views::ViewsDelegate::views_delegate->GetDefaultParentView())
return new NativeTabContentsContainerViews(container);
return new NativeTabContentsContainerGtk(container);
}
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_views.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_views.cc
index 1849428..6a2bec9 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_views.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_views.cc
@@ -66,9 +66,12 @@ views::View* NativeTabContentsContainerViews::GetView() {
void NativeTabContentsContainerViews::TabContentsFocused(
TabContents* tab_contents) {
- // This is called from RWHVViews::OnFocus, which means
- // the focus manager already set focus to RWHVViews, so don't
- // Update focus manager.
+ views::FocusManager* focus_manager = GetFocusManager();
+ if (!focus_manager) {
+ NOTREACHED();
+ return;
+ }
+ focus_manager->SetFocusedView(this);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc
index 750dc45..6045638 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc
@@ -12,6 +12,7 @@
#include "content/browser/tab_contents/interstitial_page.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "ui/base/accessibility/accessible_view_state.h"
+#include "views/views_delegate.h"
#include "views/focus/focus_manager.h"
////////////////////////////////////////////////////////////////////////////////
@@ -156,7 +157,8 @@ gfx::NativeViewAccessible
// static
NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer(
TabContentsContainer* container) {
- if (views::Widget::IsPureViews())
+ if (views::Widget::IsPureViews() &&
+ views::ViewsDelegate::views_delegate->GetDefaultParentView())
return new NativeTabContentsContainerViews(container);
return new NativeTabContentsContainerWin(container);
}
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc
index ee2f37f..f0566e6 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc
@@ -15,6 +15,7 @@
#include "content/browser/tab_contents/tab_contents_view.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
+#include "views/views_delegate.h"
using WebKit::WebDragOperation;
using WebKit::WebDragOperationsMask;
@@ -261,7 +262,8 @@ void NativeTabContentsViewGtk::PositionConstrainedWindows(
// static
NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView(
internal::NativeTabContentsViewDelegate* delegate) {
- if (views::Widget::IsPureViews())
+ if (views::Widget::IsPureViews() &&
+ views::ViewsDelegate::views_delegate->GetDefaultParentView())
return new NativeTabContentsViewViews(delegate);
return new NativeTabContentsViewGtk(delegate);
}
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.cc
index d143b61..9ed403e 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.cc
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.cc
@@ -25,33 +25,6 @@ NativeTabContentsViewViews::~NativeTabContentsViewViews() {
}
////////////////////////////////////////////////////////////////////////////////
-// NativeTabContentsViewViews, NativeWidgetViews implementation:
-void NativeTabContentsViewViews::OnBoundsChanged(
- const gfx::Rect& new_bounds, const gfx::Rect& old_bounds) {
- // TODO(oshima): Find out if we need to adjust constrained window.
- delegate_->OnNativeTabContentsViewSized(new_bounds.size());
- views::NativeWidgetViews::OnBoundsChanged(new_bounds, old_bounds);
-}
-
-bool NativeTabContentsViewViews::OnMouseEvent(const views::MouseEvent& event) {
- if (!delegate_->IsShowingSadTab()) {
- switch (event.type()) {
- case ui::ET_MOUSE_EXITED:
- delegate_->OnNativeTabContentsViewMouseMove(false);
- break;
- case ui::ET_MOUSE_MOVED:
- delegate_->OnNativeTabContentsViewMouseMove(true);
- break;
- default:
- // TODO(oshima): mouse wheel
- break;
- }
- }
- // Pass all mouse event to renderer.
- return views::NativeWidgetViews::OnMouseEvent(event);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// NativeTabContentsViewViews, NativeTabContentsView implementation:
void NativeTabContentsViewViews::InitNativeTabContentsView() {
@@ -115,11 +88,3 @@ void NativeTabContentsViewViews::SetDragCursor(
views::NativeWidget* NativeTabContentsViewViews::AsNativeWidget() {
return this;
}
-
-#if defined(TOUCH_UI)
-// static
-NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView(
- internal::NativeTabContentsViewDelegate* delegate) {
- return new NativeTabContentsViewViews(delegate);
-}
-#endif
diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.h b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.h
index f7961ba..feacb03 100644
--- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.h
+++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_views.h
@@ -11,10 +11,6 @@
class TabContents;
-namespace views {
-class MouseEvent;
-}
-
class NativeTabContentsViewViews : public views::NativeWidgetViews,
public NativeTabContentsView {
public:
@@ -23,11 +19,6 @@ class NativeTabContentsViewViews : public views::NativeWidgetViews,
virtual ~NativeTabContentsViewViews();
private:
- // Overridden from NativeWidgetViews:
- virtual void OnBoundsChanged(const gfx::Rect& new_bounds,
- const gfx::Rect& old_bounds) OVERRIDE;
- virtual bool OnMouseEvent(const views::MouseEvent& event) OVERRIDE;
-
// Overridden from NativeTabContentsView:
virtual void InitNativeTabContentsView() OVERRIDE;
virtual void Unparent() OVERRIDE;
diff --git a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
index e7fa35a..efd7593 100644
--- a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
+++ b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
@@ -17,6 +16,13 @@
#include "views/controls/menu/menu_model_adapter.h"
#include "views/controls/menu/menu_runner.h"
+#if defined(TOUCH_UI)
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
+#include "views/widget/widget.h"
+#else
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
+#endif
+
////////////////////////////////////////////////////////////////////////////////
// RenderViewContextMenuViews, public:
@@ -31,9 +37,17 @@ RenderViewContextMenuViews::~RenderViewContextMenuViews() {
}
void RenderViewContextMenuViews::RunMenuAt(int x, int y) {
+#if defined(TOUCH_UI)
+ // TODO(oshima): Eliminate this once TabContentsViewTouch is replaced
+ // with TabContentsViewViews.
+ TabContentsViewTouch* touch =
+ static_cast<TabContentsViewTouch*>(source_tab_contents_->view());
+ views::Widget* parent = touch->GetWidget()->GetTopLevelWidget();
+#else
TabContentsViewViews* tab =
static_cast<TabContentsViewViews*>(source_tab_contents_->view());
views::Widget* parent = tab->GetTopLevelWidget();
+#endif
if (menu_runner_->RunMenuAt(parent, NULL,
gfx::Rect(gfx::Point(x, y), gfx::Size()),
views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) ==
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container.h b/chrome/browser/ui/views/tab_contents/tab_contents_container.h
index 67a3159..1777479 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_container.h
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.h
@@ -16,11 +16,10 @@
// views-only code is in tab_contents_container_views.cc and native-widget only
// code is in tab_contents_container_native.cc. The headers are distinct
// because the classes have different member variables.
-
-// TODO(oshima): Rename tab_contents_container_native to tab_contents_container.
-// TODO(oshima): Figure out if we can consolidate
-// native_tab_contents_containers.
-
+#if defined(TOUCH_UI)
+#include "chrome/browser/ui/views/tab_contents/tab_contents_container_views.h"
+#else
#include "chrome/browser/ui/views/tab_contents/tab_contents_container_native.h"
+#endif
#endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_CONTAINER_H_
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container_native.cc b/chrome/browser/ui/views/tab_contents/tab_contents_container_native.cc
index 69633aa..28ce5f2 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_container_native.cc
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_container_native.cc
@@ -4,10 +4,6 @@
#include "chrome/browser/ui/views/tab_contents/tab_contents_container.h"
-#if defined(HAVE_XINPUT2)
-#include <X11/extensions/XInput2.h>
-#endif
-
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -73,48 +69,6 @@ void TabContentsContainer::Layout() {
}
}
-#if defined(HAVE_XINPUT2)
-bool TabContentsContainer::OnMousePressed(const views::MouseEvent& event) {
- DCHECK(tab_contents_);
- if (event.flags() & (ui::EF_LEFT_BUTTON_DOWN |
- ui::EF_RIGHT_BUTTON_DOWN |
- ui::EF_MIDDLE_BUTTON_DOWN)) {
- return false;
- }
- // It is necessary to look at the native event to determine what special
- // button was pressed.
- views::NativeEvent2 native_event = event.native_event_2();
- if (!native_event)
- return false;
-
- int button = 0;
- switch (native_event->type) {
- case ButtonPress: {
- button = native_event->xbutton.button;
- break;
- }
- case GenericEvent: {
- XIDeviceEvent* xievent =
- static_cast<XIDeviceEvent*>(native_event->xcookie.data);
- button = xievent->detail;
- break;
- }
- default:
- break;
- }
- switch (button) {
- case 8:
- tab_contents_->controller().GoBack();
- return true;
- case 9:
- tab_contents_->controller().GoForward();
- return true;
- }
-
- return false;
-}
-#endif
-
void TabContentsContainer::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container_native.h b/chrome/browser/ui/views/tab_contents/tab_contents_container_native.h
index 528b5f0..da28347 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_container_native.h
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_container_native.h
@@ -49,9 +49,6 @@ class TabContentsContainer : public views::View,
// Overridden from views::View:
virtual void Layout() OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
-#if defined(HAVE_XINPUT2)
- virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
-#endif
protected:
// Overridden from views::View:
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_touch.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_touch.cc
new file mode 100644
index 0000000..1e13c51
--- /dev/null
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_touch.cc
@@ -0,0 +1,430 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
+
+#include <X11/extensions/XInput2.h>
+#undef Status
+
+#include "base/string_util.h"
+#include "build/build_config.h"
+#include "chrome/browser/renderer_host/render_widget_host_view_views.h"
+#include "chrome/browser/ui/views/sad_tab_view.h"
+#include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/renderer_host/render_view_host_factory.h"
+#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/tab_contents_delegate.h"
+#include "ui/gfx/canvas_skia_paint.h"
+#include "ui/gfx/point.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/size.h"
+#include "views/controls/native/native_view_host.h"
+#include "views/focus/focus_manager.h"
+#include "views/focus/view_storage.h"
+#include "views/layout/fill_layout.h"
+#include "views/widget/widget.h"
+
+using WebKit::WebDragOperation;
+using WebKit::WebDragOperationsMask;
+using WebKit::WebInputEvent;
+
+// static
+const char TabContentsViewTouch::kViewClassName[] =
+ "browser/ui/views/tab_contents/TabContentsViewTouch";
+
+TabContentsViewTouch::TabContentsViewTouch(TabContents* tab_contents)
+ : tab_contents_(tab_contents),
+ sad_tab_(NULL),
+ ignore_next_char_event_(false) {
+ last_focused_view_storage_id_ =
+ views::ViewStorage::GetInstance()->CreateStorageID();
+ SetLayoutManager(new views::FillLayout());
+}
+
+TabContentsViewTouch::~TabContentsViewTouch() {
+ // Make sure to remove any stored view we may still have in the ViewStorage.
+ //
+ // It is possible the view went away before us, so we only do this if the
+ // view is registered.
+ views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
+ if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL)
+ view_storage->RemoveView(last_focused_view_storage_id_);
+}
+
+void TabContentsViewTouch::AttachConstrainedWindow(
+ ConstrainedWindowGtk* constrained_window) {
+ // TODO(anicolao): reimplement all dialogs as WebUI
+ NOTIMPLEMENTED();
+}
+
+void TabContentsViewTouch::RemoveConstrainedWindow(
+ ConstrainedWindowGtk* constrained_window) {
+ // TODO(anicolao): reimplement all dialogs as WebUI
+ NOTIMPLEMENTED();
+}
+
+void TabContentsViewTouch::CreateView(const gfx::Size& initial_size) {
+ SetBoundsRect(gfx::Rect(bounds().origin(), initial_size));
+}
+
+RenderWidgetHostView* TabContentsViewTouch::CreateViewForWidget(
+ RenderWidgetHost* render_widget_host) {
+ if (render_widget_host->view()) {
+ // During testing, the view will already be set up in most cases to the
+ // test view, so we don't want to clobber it with a real one. To verify that
+ // this actually is happening (and somebody isn't accidentally creating the
+ // view twice), we check for the RVH Factory, which will be set when we're
+ // making special ones (which go along with the special views).
+ DCHECK(RenderViewHostFactory::has_factory());
+ return render_widget_host->view();
+ }
+
+ // If we were showing sad tab, remove it now.
+ if (sad_tab_ != NULL) {
+ RemoveChildView(sad_tab_.get());
+ sad_tab_.reset();
+ }
+
+ RenderWidgetHostViewViews* view =
+ new RenderWidgetHostViewViews(render_widget_host);
+ AddChildView(view);
+ view->Show();
+ view->InitAsChild();
+
+ // TODO(anicolao): implement drag'n'drop hooks if needed
+
+ return view;
+}
+
+gfx::NativeView TabContentsViewTouch::GetNativeView() const {
+ return GetWidget()->GetNativeView();
+}
+
+gfx::NativeView TabContentsViewTouch::GetContentNativeView() const {
+ RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
+ if (!rwhv)
+ return NULL;
+ return rwhv->GetNativeView();
+}
+
+gfx::NativeWindow TabContentsViewTouch::GetTopLevelNativeWindow() const {
+ GtkWidget* window = gtk_widget_get_ancestor(GetNativeView(), GTK_TYPE_WINDOW);
+ return window ? GTK_WINDOW(window) : NULL;
+}
+
+void TabContentsViewTouch::GetContainerBounds(gfx::Rect* out) const {
+ *out = bounds();
+}
+
+void TabContentsViewTouch::StartDragging(const WebDropData& drop_data,
+ WebDragOperationsMask ops,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) {
+ // TODO(anicolao): implement dragging
+}
+
+void TabContentsViewTouch::SetPageTitle(const std::wstring& title) {
+ // TODO(anicolao): figure out if there's anything useful to do here
+}
+
+void TabContentsViewTouch::OnTabCrashed(base::TerminationStatus status,
+ int /* error_code */) {
+ if (sad_tab_ != NULL)
+ return;
+
+ sad_tab_.reset(new SadTabView(
+ tab_contents_,
+ status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ?
+ SadTabView::KILLED : SadTabView::CRASHED));
+ RemoveAllChildViews(true);
+ AddChildView(sad_tab_.get());
+ Layout();
+}
+
+void TabContentsViewTouch::SizeContents(const gfx::Size& size) {
+ WasSized(size);
+
+ // We need to send this immediately.
+ RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
+ if (rwhv)
+ rwhv->SetSize(size);
+}
+
+void TabContentsViewTouch::RenderViewCreated(RenderViewHost* host) {
+}
+
+void TabContentsViewTouch::Focus() {
+ if (tab_contents_->interstitial_page()) {
+ tab_contents_->interstitial_page()->Focus();
+ return;
+ }
+
+ if (tab_contents_->is_crashed() && sad_tab_ != NULL) {
+ sad_tab_->RequestFocus();
+ return;
+ }
+
+ RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
+ if (rwhv)
+ rwhv->Focus();
+}
+
+void TabContentsViewTouch::SetInitialFocus() {
+ if (tab_contents_->FocusLocationBarByDefault())
+ tab_contents_->SetFocusToLocationBar(false);
+ else
+ Focus();
+}
+
+void TabContentsViewTouch::StoreFocus() {
+ views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
+
+ if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL)
+ view_storage->RemoveView(last_focused_view_storage_id_);
+
+ views::FocusManager* focus_manager = GetFocusManager();
+ if (focus_manager) {
+ // |focus_manager| can be NULL if the tab has been detached but still
+ // exists.
+ views::View* focused_view = focus_manager->GetFocusedView();
+ if (focused_view)
+ view_storage->StoreView(last_focused_view_storage_id_, focused_view);
+ }
+}
+
+void TabContentsViewTouch::RestoreFocus() {
+ views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
+ views::View* last_focused_view =
+ view_storage->RetrieveView(last_focused_view_storage_id_);
+ if (!last_focused_view) {
+ SetInitialFocus();
+ } else {
+ views::FocusManager* focus_manager = GetFocusManager();
+
+ // If you hit this DCHECK, please report it to Jay (jcampan).
+ DCHECK(focus_manager != NULL) << "No focus manager when restoring focus.";
+
+ if (last_focused_view->IsFocusableInRootView() && focus_manager &&
+ focus_manager->ContainsView(last_focused_view)) {
+ last_focused_view->RequestFocus();
+ } else {
+ // The focused view may not belong to the same window hierarchy (e.g.
+ // if the location bar was focused and the tab is dragged out), or it may
+ // no longer be focusable (e.g. if the location bar was focused and then
+ // we switched to fullscreen mode). In that case we default to the
+ // default focus.
+ SetInitialFocus();
+ }
+ view_storage->RemoveView(last_focused_view_storage_id_);
+ }
+}
+
+bool TabContentsViewTouch::IsDoingDrag() const {
+ return false;
+}
+
+void TabContentsViewTouch::CancelDragAndCloseTab() {
+}
+
+bool TabContentsViewTouch::IsEventTracking() const {
+ return false;
+}
+
+void TabContentsViewTouch::CloseTabAfterEventTracking() {
+}
+
+void TabContentsViewTouch::GetViewBounds(gfx::Rect* out) const {
+ out->SetRect(x(), y(), width(), height());
+}
+
+bool TabContentsViewTouch::OnMousePressed(const views::MouseEvent& event) {
+ if ((event.flags() & (ui::EF_LEFT_BUTTON_DOWN |
+ ui::EF_RIGHT_BUTTON_DOWN |
+ ui::EF_MIDDLE_BUTTON_DOWN))) {
+ return false;
+ }
+
+ // It is necessary to look at the native event to determine what special
+ // button was pressed.
+ views::NativeEvent2 native_event = event.native_event_2();
+ if (!native_event)
+ return false;
+
+ int button = 0;
+ switch (native_event->type) {
+ case ButtonPress: {
+ button = native_event->xbutton.button;
+ break;
+ }
+ case GenericEvent: {
+ XIDeviceEvent* xievent =
+ static_cast<XIDeviceEvent*>(native_event->xcookie.data);
+ button = xievent->detail;
+ break;
+ }
+ default:
+ break;
+ }
+
+ switch (button) {
+ case 8:
+ tab_contents_->controller().GoBack();
+ return true;
+ case 9:
+ tab_contents_->controller().GoForward();
+ return true;
+ }
+
+ return false;
+}
+
+void TabContentsViewTouch::OnBoundsChanged(const gfx::Rect& previous_bounds) {
+ if (IsVisibleInRootView())
+ WasSized(size());
+}
+
+void TabContentsViewTouch::OnPaint(gfx::Canvas* canvas) {
+}
+
+std::string TabContentsViewTouch::GetClassName() const {
+ return kViewClassName;
+}
+
+void TabContentsViewTouch::UpdateDragCursor(WebDragOperation operation) {
+ NOTIMPLEMENTED();
+ // It's not even clear a drag cursor will make sense for touch.
+ // TODO(anicolao): implement dragging
+}
+
+void TabContentsViewTouch::GotFocus() {
+ if (tab_contents_->delegate())
+ tab_contents_->delegate()->TabContentsFocused(tab_contents_);
+}
+
+void TabContentsViewTouch::TakeFocus(bool reverse) {
+ if (tab_contents_->delegate() &&
+ !tab_contents_->delegate()->TakeFocus(reverse)) {
+
+ views::FocusManager* focus_manager = GetFocusManager();
+
+ // We may not have a focus manager if the tab has been switched before this
+ // message arrived.
+ if (focus_manager)
+ focus_manager->AdvanceFocus(reverse);
+ }
+}
+
+void TabContentsViewTouch::VisibilityChanged(views::View *, bool is_visible) {
+ if (is_visible) {
+ WasShown();
+ } else {
+ WasHidden();
+ }
+}
+
+
+void TabContentsViewTouch::CreateNewWindow(
+ int route_id,
+ const ViewHostMsg_CreateWindow_Params& params) {
+ delegate_view_helper_.CreateNewWindowFromTabContents(
+ tab_contents_, route_id, params);
+}
+
+void TabContentsViewTouch::CreateNewWidget(
+ int route_id, WebKit::WebPopupType popup_type) {
+ delegate_view_helper_.CreateNewWidget(route_id, popup_type,
+ tab_contents_->render_view_host()->process());
+}
+
+void TabContentsViewTouch::CreateNewFullscreenWidget(int route_id) {
+ delegate_view_helper_.CreateNewFullscreenWidget(
+ route_id, tab_contents_->render_view_host()->process());
+}
+
+void TabContentsViewTouch::ShowCreatedWindow(int route_id,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture) {
+ delegate_view_helper_.ShowCreatedWindow(
+ tab_contents_, route_id, disposition, initial_pos, user_gesture);
+}
+
+void TabContentsViewTouch::ShowCreatedWidget(
+ int route_id, const gfx::Rect& initial_pos) {
+ delegate_view_helper_.ShowCreatedWidget(
+ tab_contents_, route_id, initial_pos);
+}
+
+void TabContentsViewTouch::ShowCreatedFullscreenWidget(int route_id) {
+ delegate_view_helper_.ShowCreatedFullscreenWidget(tab_contents_, route_id);
+}
+
+void TabContentsViewTouch::ShowContextMenu(const ContextMenuParams& params) {
+ // Allow delegates to handle the context menu operation first.
+ if (tab_contents_->delegate() &&
+ tab_contents_->delegate()->HandleContextMenu(params))
+ return;
+
+ context_menu_.reset(new RenderViewContextMenuViews(tab_contents_, params));
+ context_menu_->Init();
+
+ gfx::Point screen_point(params.x, params.y);
+ RenderWidgetHostViewViews* rwhv = static_cast<RenderWidgetHostViewViews*>
+ (tab_contents_->GetRenderWidgetHostView());
+ if (rwhv) {
+ views::View::ConvertPointToScreen(rwhv, &screen_point);
+ }
+
+ // Enable recursive tasks on the message loop so we can get updates while
+ // the context menu is being displayed.
+ bool old_state = MessageLoop::current()->NestableTasksAllowed();
+ MessageLoop::current()->SetNestableTasksAllowed(true);
+ context_menu_->RunMenuAt(screen_point.x(), screen_point.y());
+ MessageLoop::current()->SetNestableTasksAllowed(old_state);
+}
+
+void TabContentsViewTouch::ShowPopupMenu(const gfx::Rect& bounds,
+ int item_height,
+ double item_font_size,
+ int selected_item,
+ const std::vector<WebMenuItem>& items,
+ bool right_aligned) {
+ // External popup menus are only used on Mac.
+ NOTREACHED();
+}
+
+void TabContentsViewTouch::WasHidden() {
+ tab_contents_->HideContents();
+}
+
+void TabContentsViewTouch::WasShown() {
+ tab_contents_->ShowContents();
+}
+
+void TabContentsViewTouch::WasSized(const gfx::Size& size) {
+ // We have to check that the RenderWidgetHostView is the proper size.
+ // It can be wrong in cases where the renderer has died and the host
+ // view needed to be recreated.
+ bool needs_resize = size != size_;
+
+ if (needs_resize) {
+ size_ = size;
+ if (tab_contents_->interstitial_page())
+ tab_contents_->interstitial_page()->SetSize(size);
+ }
+
+ RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
+ if (rwhv && rwhv->GetViewBounds().size() != size)
+ rwhv->SetSize(size);
+
+ if (needs_resize)
+ SetFloatingPosition(size);
+}
+
+void TabContentsViewTouch::SetFloatingPosition(const gfx::Size& size) {
+ // TODO(anicolao): rework this once we have WebUI views for dialogs
+ SetBounds(x(), y(), size.width(), size.height());
+}
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h b/chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h
new file mode 100644
index 0000000..6397668
--- /dev/null
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h
@@ -0,0 +1,160 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_TOUCH_H_
+#define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_TOUCH_H_
+#pragma once
+
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
+#include "content/browser/tab_contents/tab_contents_view.h"
+#include "ui/gfx/size.h"
+#include "views/view.h"
+
+class ConstrainedWindowGtk;
+typedef struct _GtkFloatingContainer GtkFloatingContainer;
+class RenderViewContextMenuViews;
+class SadTabView;
+class SkBitmap;
+class TabContentsDragSource;
+class WebDragDestGtk;
+
+namespace gfx {
+class Point;
+} // namespace gfx
+
+namespace views {
+class MouseEvent;
+class NativeViewHost;
+} // namespace views
+
+// Touch-specific implementation of the TabContentsView for the touch UI.
+class TabContentsViewTouch : public TabContentsView, public views::View {
+ public:
+ // Internal class name
+ static const char kViewClassName[];
+
+ // The corresponding TabContents is passed in the constructor, and manages our
+ // lifetime. This doesn't need to be the case, but is this way currently
+ // because that's what was easiest when they were split.
+ explicit TabContentsViewTouch(TabContents* tab_contents);
+ virtual ~TabContentsViewTouch();
+
+ // Unlike Windows, ConstrainedWindows need to collaborate with the
+ // TabContentsViewTouch to position the dialogs.
+ void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window);
+ void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window);
+
+ // TabContentsView implementation
+ virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
+ virtual RenderWidgetHostView* CreateViewForWidget(
+ RenderWidgetHost* render_widget_host) OVERRIDE;
+ virtual gfx::NativeView GetNativeView() const OVERRIDE;
+ virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
+ virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
+ virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
+ virtual void SetPageTitle(const std::wstring& title) OVERRIDE;
+ virtual void OnTabCrashed(base::TerminationStatus status,
+ int error_code) OVERRIDE;
+ virtual void SizeContents(const gfx::Size& size) OVERRIDE;
+ virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
+ virtual void Focus() OVERRIDE;
+ virtual void SetInitialFocus() OVERRIDE;
+ virtual void StoreFocus() OVERRIDE;
+ virtual void RestoreFocus() OVERRIDE;
+ virtual bool IsDoingDrag() const OVERRIDE;
+ virtual void CancelDragAndCloseTab() OVERRIDE;
+ virtual bool IsEventTracking() const OVERRIDE;
+ virtual void CloseTabAfterEventTracking() OVERRIDE;
+ virtual void GetViewBounds(gfx::Rect* out) const OVERRIDE;
+
+ // views::View implementation
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual std::string GetClassName() const OVERRIDE;
+
+ // Backend implementation of RenderViewHostDelegate::View.
+ virtual void CreateNewWindow(
+ int route_id,
+ const ViewHostMsg_CreateWindow_Params& params);
+ virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type);
+ virtual void CreateNewFullscreenWidget(int route_id);
+ virtual void ShowCreatedWindow(int route_id,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture);
+ virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos);
+ virtual void ShowCreatedFullscreenWidget(int route_id);
+ virtual void ShowContextMenu(const ContextMenuParams& params);
+ virtual void ShowPopupMenu(const gfx::Rect& bounds,
+ int item_height,
+ double item_font_size,
+ int selected_item,
+ const std::vector<WebMenuItem>& items,
+ bool right_aligned) OVERRIDE;
+ virtual void StartDragging(const WebDropData& drop_data,
+ WebKit::WebDragOperationsMask ops_allowed,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) OVERRIDE;
+ virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
+ virtual void GotFocus() OVERRIDE;
+ virtual void TakeFocus(bool reverse) OVERRIDE;
+ virtual void VisibilityChanged(views::View *, bool is_visible) OVERRIDE;
+
+ private:
+ // Signal handlers -----------------------------------------------------------
+
+ // Handles notifying the TabContents and other operations when the window was
+ // shown or hidden.
+ void WasHidden();
+ void WasShown();
+
+ // Handles resizing of the contents. This will notify the RenderWidgetHostView
+ // of the change, reposition popups, and the find in page bar.
+ void WasSized(const gfx::Size& size);
+
+ // For any floating views (ConstrainedDialogs) this function centers them
+ // within this view. It's called whem a ConstrainedDialog is attached and
+ // when this view is resized.
+ void SetFloatingPosition(const gfx::Size& size);
+
+ // The TabContents whose contents we display.
+ TabContents* tab_contents_;
+
+ // Common implementations of some RenderViewHostDelegate::View methods.
+ RenderViewHostDelegateViewHelper delegate_view_helper_;
+
+ // Used to render the sad tab. This will be non-NULL only when the sad tab is
+ // visible.
+ scoped_ptr<SadTabView> sad_tab_;
+
+ // Whether to ignore the next CHAR keyboard event.
+ bool ignore_next_char_event_;
+
+ // The id used in the ViewStorage to store the last focused view.
+ int last_focused_view_storage_id_;
+
+ // The context menu. Callbacks are asynchronous so we need to keep it around.
+ scoped_ptr<RenderViewContextMenuViews> context_menu_;
+
+ // Handle drags from this TabContentsView.
+ // TODO(anicolao): figure out what's needed for drag'n'drop
+
+ // The event for the last mouse down we handled. We need this for drags.
+ GdkEventButton last_mouse_down_;
+
+ // Current size. See comment in NativeWidgetGtk as to why this is cached.
+ gfx::Size size_;
+
+ // Each individual UI for constrained dialogs currently displayed. The
+ // objects in this vector are owned by the TabContents, not the view.
+ std::vector<ConstrainedWindowGtk*> constrained_windows_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabContentsViewTouch);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_TOUCH_H_
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
index 117ba35..0eab11bb 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc
@@ -52,17 +52,10 @@ TabContentsViewViews::~TabContentsViewViews() {
view_storage->RemoveView(last_focused_view_storage_id_);
}
-void TabContentsViewViews::AttachConstrainedWindow(
- ConstrainedWindowGtk* constrained_window) {
-}
-void TabContentsViewViews::RemoveConstrainedWindow(
- ConstrainedWindowGtk* constrained_window) {
-}
-
void TabContentsViewViews::Unparent() {
// Remember who our FocusManager is, we won't be able to access it once
// un-parented.
- focus_manager_ = Widget::GetFocusManager();
+ focus_manager_ = GetFocusManager();
CHECK(native_tab_contents_view_);
native_tab_contents_view_->Unparent();
}
@@ -171,15 +164,10 @@ void TabContentsViewViews::Focus() {
}
RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
- if (rwhv) {
- rwhv->Focus();
- } else {
- views::FocusManager* focus_manager = GetFocusManager();
- // TODO(oshima): There is no native view for RWHVViews.
- // Consider Widget::Focus().
- if (focus_manager)
- focus_manager->FocusNativeView(GetNativeView());
- }
+ views::FocusManager* focus_manager = GetFocusManager();
+ if (focus_manager)
+ focus_manager->FocusNativeView(rwhv ? rwhv->GetNativeView()
+ : GetNativeView());
}
void TabContentsViewViews::SetInitialFocus() {
@@ -266,8 +254,7 @@ void TabContentsViewViews::GotFocus() {
}
void TabContentsViewViews::TakeFocus(bool reverse) {
- if (tab_contents_->delegate() &&
- !tab_contents_->delegate()->TakeFocus(reverse)) {
+ if (!tab_contents_->delegate()->TakeFocus(reverse)) {
views::FocusManager* focus_manager = GetFocusManager();
// We may not have a focus manager if the tab has been switched before this
diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h
index fa29b6a..b41f796 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h
@@ -13,7 +13,6 @@
#include "content/browser/tab_contents/tab_contents_view.h"
#include "views/widget/widget.h"
-class ConstrainedWindowGtk;
class NativeTabContentsView;
class RenderViewContextMenuViews;
class SadTabView;
@@ -40,11 +39,6 @@ class TabContentsViewViews : public views::Widget,
explicit TabContentsViewViews(TabContents* tab_contents);
virtual ~TabContentsViewViews();
- // Intermediate code to pass comiplation. This will be removed as a
- // part of ConstraintWindow change (http://codereview.chromium.org/7631049).
- void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window);
- void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window);
-
// Reset the native parent of this view to NULL. Unparented windows should
// not receive any messages.
virtual void Unparent();
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 23be513..a640c62 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3424,8 +3424,12 @@
'browser/ui/views/tab_contents/tab_contents_container.h',
'browser/ui/views/tab_contents/tab_contents_container_native.cc',
'browser/ui/views/tab_contents/tab_contents_container_native.h',
+ 'browser/ui/views/tab_contents/tab_contents_container_views.cc',
+ 'browser/ui/views/tab_contents/tab_contents_container_views.h',
'browser/ui/views/tab_contents/tab_contents_drag_win.cc',
'browser/ui/views/tab_contents/tab_contents_drag_win.h',
+ 'browser/ui/views/tab_contents/tab_contents_view_touch.cc',
+ 'browser/ui/views/tab_contents/tab_contents_view_touch.h',
'browser/ui/views/tab_contents/tab_contents_view_views.cc',
'browser/ui/views/tab_contents/tab_contents_view_views.h',
'browser/ui/views/tab_icon_view.cc',
@@ -3973,6 +3977,9 @@
['exclude', '^browser/renderer_host/accelerated_surface_container_touch.h'],
['exclude', '^browser/renderer_host/render_widget_host_view_views_touch.cc'],
['exclude', '^browser/ui/touch/*'],
+ ['exclude', '^browser/ui/views/tab_contents/tab_contents_container_views.cc'],
+ ['exclude', '^browser/ui/views/tab_contents/tab_contents_container_views.h'],
+ ['exclude', '^browser/ui/views/tab_contents/tab_contents_view_touch.*'],
['exclude', '^browser/ui/webui/keyboard_ui.*'],
],
}],
@@ -3988,6 +3995,7 @@
['exclude', '^browser/renderer_host/render_widget_host_view_gtk.h'],
['exclude', '^browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc'],
['exclude', '^browser/ui/views/handle_web_keyboard_event_gtk.cc'],
+ ['exclude', '^browser/ui/views/tab_contents/tab_contents_view_views.*'],
['exclude', '^browser/ui/views/tab_contents/native_tab_contents_view_gtk.*'],
['exclude', '^browser/chromeos/input_method/candidate_window.cc'],
['exclude', '^browser/chromeos/input_method/candidate_window.h'],
@@ -4816,6 +4824,8 @@
# Touch build only
['OS=="linux" and toolkit_views==1 and touchui==1', {
'sources/': [
+ ['include', '^browser/ui/views/tab_contents/tab_contents_view_touch.cc'],
+ ['include', '^browser/ui/views/tab_contents/tab_contents_view_touch.h'],
['include', '^browser/ui/views/tab_contents/tab_contents_container_views.cc'],
['include', '^browser/ui/views/tab_contents/tab_contents_container_views.h'],
# TODO(anicolao): exclude these once we have WebUI dialogs
@@ -4823,6 +4833,9 @@
# ['exclude', '^browser/ui/gtk/constrained_window_gtk.h'],
['exclude', '^browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc'],
['exclude', '^browser/ui/views/tabs/tab_strip_factory.cc'],
+ ['exclude', '^browser/ui/views/tab_contents/tab_contents_container_native.cc'],
+ ['exclude', '^browser/ui/views/tab_contents/tab_contents_container_native.h'],
+ ['exclude', '^browser/ui/views/tab_contents/tab_contents_view_views.*'],
['exclude', '^browser/ui/views/tab_contents/native_tab_contents_view_gtk.*'],
],
}],
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc
index e9d8f61..64f4795 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -258,7 +258,9 @@ int MenuButton::GetMaximumScreenXCoordinate() {
return 0;
}
- gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
+ gfx::Rect monitor_bounds =
+ gfx::Screen::GetMonitorWorkAreaNearestWindow(
+ GetWidget()->GetTopLevelWidget()->GetNativeView());
return monitor_bounds.right() - 1;
}
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index d1eeb23..7cb5892 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -1333,10 +1333,6 @@ bool NativeWidgetGtk::ConvertPointFromAncestor(
return false;
}
-gfx::Rect NativeWidgetGtk::GetWorkAreaBoundsInScreen() const {
- return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView());
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetGtk, protected:
@@ -2138,20 +2134,22 @@ bool Widget::ConvertRect(const Widget* source,
DCHECK(target);
DCHECK(rect);
- // TODO(oshima): Add check if source and target belongs to the same
- // screen.
-
- if (source == target)
+ GtkWidget* source_widget = source->GetNativeView();
+ GtkWidget* target_widget = target->GetNativeView();
+ if (source_widget == target_widget)
return true;
- if (!source || !target)
- return false;
- gfx::Point source_point = source->GetWindowScreenBounds().origin();
- gfx::Point target_point = target->GetWindowScreenBounds().origin();
+ if (!source_widget || !target_widget)
+ return false;
- rect->set_origin(
- source_point.Subtract(target_point).Add(rect->origin()));
- return true;
+ GdkRectangle gdk_rect = rect->ToGdkRectangle();
+ if (gtk_widget_translate_coordinates(source_widget, target_widget,
+ gdk_rect.x, gdk_rect.y,
+ &gdk_rect.x, &gdk_rect.y)) {
+ *rect = gdk_rect;
+ return true;
+ }
+ return false;
}
namespace internal {
diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h
index fed434f..eb5ec4a 100644
--- a/views/widget/native_widget_gtk.h
+++ b/views/widget/native_widget_gtk.h
@@ -220,7 +220,6 @@ class VIEWS_EXPORT NativeWidgetGtk : public internal::NativeWidgetPrivate,
virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE;
virtual bool ConvertPointFromAncestor(
const Widget* ancestor, gfx::Point* point) const OVERRIDE;
- virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE;
protected:
// Modifies event coordinates to the targeted widget contained by this widget.
diff --git a/views/widget/native_widget_private.h b/views/widget/native_widget_private.h
index f47c5ac..dbeab12 100644
--- a/views/widget/native_widget_private.h
+++ b/views/widget/native_widget_private.h
@@ -204,7 +204,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget,
virtual void FocusNativeView(gfx::NativeView native_view) = 0;
virtual bool ConvertPointFromAncestor(
const Widget* ancestor, gfx::Point* point) const = 0;
- virtual gfx::Rect GetWorkAreaBoundsInScreen() const = 0;
// Overridden from NativeWidget:
virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE;
diff --git a/views/widget/native_widget_view.cc b/views/widget/native_widget_view.cc
index 500c614..0b60850 100644
--- a/views/widget/native_widget_view.cc
+++ b/views/widget/native_widget_view.cc
@@ -5,6 +5,10 @@
#include "views/widget/native_widget_view.h"
#include "ui/gfx/canvas.h"
+#if defined(OS_LINUX)
+#include "views/window/hit_test.h"
+#endif
+#include "views/widget/window_manager.h"
namespace views {
namespace internal {
@@ -63,7 +67,7 @@ void NativeWidgetView::ViewHierarchyChanged(bool is_add,
}
void NativeWidgetView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
- native_widget_->OnBoundsChanged(bounds(), previous_bounds);
+ delegate()->OnNativeWidgetSizeChanged(size());
}
void NativeWidgetView::OnPaint(gfx::Canvas* canvas) {
@@ -75,15 +79,46 @@ gfx::NativeCursor NativeWidgetView::GetCursor(const MouseEvent& event) {
}
bool NativeWidgetView::OnMousePressed(const MouseEvent& event) {
- return native_widget_->OnMouseEvent(event);
+ Widget* hosting_widget = GetAssociatedWidget();
+ if (hosting_widget->non_client_view()) {
+ int hittest_code = hosting_widget->non_client_view()->NonClientHitTest(
+ event.location());
+ switch (hittest_code) {
+ case HTCAPTION: {
+ if (!event.IsOnlyRightMouseButton()) {
+ WindowManager::Get()->StartMoveDrag(hosting_widget, event.location());
+ return true;
+ }
+ break;
+ }
+ case HTBOTTOM:
+ case HTBOTTOMLEFT:
+ case HTBOTTOMRIGHT:
+ case HTGROWBOX:
+ case HTLEFT:
+ case HTRIGHT:
+ case HTTOP:
+ case HTTOPLEFT:
+ case HTTOPRIGHT: {
+ WindowManager::Get()->StartResizeDrag(
+ hosting_widget, event.location(), hittest_code);
+ return true;
+ }
+ default:
+ // Everything else falls into standard client event handling...
+ break;
+ }
+ }
+
+ return delegate()->OnMouseEvent(event);
}
bool NativeWidgetView::OnMouseDragged(const MouseEvent& event) {
- return native_widget_->OnMouseEvent(event);
+ return delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseReleased(const MouseEvent& event) {
- native_widget_->OnMouseEvent(event);
+ delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseCaptureLost() {
@@ -91,15 +126,15 @@ void NativeWidgetView::OnMouseCaptureLost() {
}
void NativeWidgetView::OnMouseMoved(const MouseEvent& event) {
- native_widget_->OnMouseEvent(event);
+ delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseEntered(const MouseEvent& event) {
- native_widget_->OnMouseEvent(event);
+ delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseExited(const MouseEvent& event) {
- native_widget_->OnMouseEvent(event);
+ delegate()->OnMouseEvent(event);
}
ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) {
@@ -115,7 +150,7 @@ bool NativeWidgetView::OnKeyReleased(const KeyEvent& event) {
}
bool NativeWidgetView::OnMouseWheel(const MouseWheelEvent& event) {
- return native_widget_->OnMouseEvent(event);
+ return delegate()->OnMouseEvent(event);
}
void NativeWidgetView::VisibilityChanged(View* starting_from,
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc
index 68b9c0e..44f2d9d 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -18,10 +18,6 @@
#include "views/ime/mock_input_method.h"
#endif
-#if defined(OS_LINUX)
-#include "views/window/hit_test.h"
-#endif
-
namespace views {
////////////////////////////////////////////////////////////////////////////////
@@ -34,6 +30,7 @@ NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate)
minimized_(false),
always_on_top_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
+ hosting_widget_(NULL),
ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
delete_native_view_(true) {
}
@@ -98,18 +95,6 @@ void NativeWidgetViews::DispatchKeyEventPostIME(const KeyEvent& key) {
}
////////////////////////////////////////////////////////////////////////////////
-// NativeWidgetViews, protected:
-
-void NativeWidgetViews::OnBoundsChanged(const gfx::Rect& new_bounds,
- const gfx::Rect& old_bounds) {
- delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
-}
-
-bool NativeWidgetViews::OnMouseEvent(const MouseEvent& event) {
- return HandleWindowOperation(event) ? true : delegate_->OnMouseEvent(event);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// NativeWidgetViews, NativeWidget implementation:
void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
@@ -117,12 +102,11 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
always_on_top_ = params.keep_on_top;
View* parent_view = NULL;
if (params.parent_widget) {
- parent_view = params.parent_widget->GetChildViewParent();
- } else if (ViewsDelegate::views_delegate->GetDefaultParentView()) {
+ hosting_widget_ = params.parent_widget;
+ parent_view = hosting_widget_->GetChildViewParent();
+ } else {
parent_view = ViewsDelegate::views_delegate->GetDefaultParentView();
- } else if (params.parent) {
- Widget* widget = Widget::GetWidgetForNativeView(params.parent);
- parent_view = widget->GetChildViewParent();
+ hosting_widget_ = parent_view->GetWidget();
}
view_ = new internal::NativeWidgetView(this);
@@ -140,8 +124,7 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET)
view_->set_delete_native_widget(false);
- if (parent_view)
- parent_view->AddChildView(view_);
+ parent_view->AddChildView(view_);
// TODO(beng): SetInitParams().
}
@@ -193,11 +176,11 @@ Widget* NativeWidgetViews::GetTopLevelWidget() {
}
const ui::Compositor* NativeWidgetViews::GetCompositor() const {
- return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL;
+ return hosting_widget_->GetCompositor();
}
ui::Compositor* NativeWidgetViews::GetCompositor() {
- return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL;
+ return hosting_widget_->GetCompositor();
}
void NativeWidgetViews::MarkLayerDirty() {
@@ -487,7 +470,7 @@ void NativeWidgetViews::RunShellDrag(View* view,
}
void NativeWidgetViews::SchedulePaintInRect(const gfx::Rect& rect) {
- view_->SchedulePaintInRect(rect);
+ view_->SchedulePaintInternal(rect);
}
void NativeWidgetViews::SetCursor(gfx::NativeCursor cursor) {
@@ -524,13 +507,6 @@ bool NativeWidgetViews::ConvertPointFromAncestor(
return false;
}
-gfx::Rect NativeWidgetViews::GetWorkAreaBoundsInScreen() const {
- // TODO(oshima): This should return the views desktop window's
- // working area when the system is running under views desktop
- // rather than native window's working area.
- return GetParentNativeWidget()->GetWorkAreaBoundsInScreen();
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetViews, private:
@@ -549,41 +525,4 @@ const internal::NativeWidgetPrivate*
NULL;
}
-bool NativeWidgetViews::HandleWindowOperation(const MouseEvent& event) {
- if (event.type() != ui::ET_MOUSE_PRESSED)
- return false;
-
- Widget* widget = GetWidget();
- if (widget->non_client_view()) {
- int hittest_code = widget->non_client_view()->NonClientHitTest(
- event.location());
- switch (hittest_code) {
- case HTCAPTION: {
- if (!event.IsOnlyRightMouseButton()) {
- WindowManager::Get()->StartMoveDrag(widget, event.location());
- return true;
- }
- break;
- }
- case HTBOTTOM:
- case HTBOTTOMLEFT:
- case HTBOTTOMRIGHT:
- case HTGROWBOX:
- case HTLEFT:
- case HTRIGHT:
- case HTTOP:
- case HTTOPLEFT:
- case HTTOPRIGHT: {
- WindowManager::Get()->StartResizeDrag(
- widget, event.location(), hittest_code);
- return true;
- }
- default:
- // Everything else falls into standard client event handling.
- break;
- }
- }
- return false;
-}
-
} // namespace views
diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h
index b0c2ea3..eaa2804 100644
--- a/views/widget/native_widget_views.h
+++ b/views/widget/native_widget_views.h
@@ -47,12 +47,7 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate {
internal::NativeWidgetDelegate* delegate() const { return delegate_; }
protected:
- friend class internal::NativeWidgetView;
-
- // Event handlers that subclass can implmenet custom behavior.
- virtual void OnBoundsChanged(const gfx::Rect& new_bounds,
- const gfx::Rect& old_bounds);
- virtual bool OnMouseEvent(const MouseEvent& event);
+ friend class NativeWidgetView;
// Overridden from internal::NativeWidgetPrivate:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
@@ -135,7 +130,6 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate {
virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE;
virtual bool ConvertPointFromAncestor(
const Widget* ancestor, gfx::Point* point) const OVERRIDE;
- virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE;
// Overridden from internal::InputMethodDelegate
virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE;
@@ -147,8 +141,6 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate {
internal::NativeWidgetPrivate* GetParentNativeWidget();
const internal::NativeWidgetPrivate* GetParentNativeWidget() const;
- bool HandleWindowOperation(const MouseEvent& event);
-
internal::NativeWidgetDelegate* delegate_;
internal::NativeWidgetView* view_;
@@ -167,6 +159,8 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate {
gfx::Rect restored_bounds_;
ui::Transform restored_transform_;
+ Widget* hosting_widget_;
+
// See class documentation for Widget in widget.h for a note about ownership.
Widget::InitParams::Ownership ownership_;
diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc
index b75a4a9..23ef015 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -1092,10 +1092,6 @@ bool NativeWidgetWin::ConvertPointFromAncestor(
return false;
}
-gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const {
- return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView());
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetWin, MessageLoop::Observer implementation:
diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h
index 43b4a76..967ed85 100644
--- a/views/widget/native_widget_win.h
+++ b/views/widget/native_widget_win.h
@@ -266,7 +266,6 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE;
virtual bool ConvertPointFromAncestor(
const Widget* ancestor, gfx::Point* point) const OVERRIDE;
- virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE;
protected:
// Information saved before going into fullscreen mode, used to restore the
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index 39e7e8b..8ed6c8d 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -604,7 +604,7 @@ ThemeProvider* Widget::GetThemeProvider() const {
}
FocusManager* Widget::GetFocusManager() {
- const Widget* toplevel_widget = GetTopLevelWidget();
+ Widget* toplevel_widget = GetTopLevelWidget();
return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL;
}
@@ -803,10 +803,6 @@ View* Widget::GetChildViewParent() {
return GetContentsView() ? GetContentsView() : GetRootView();
}
-gfx::Rect Widget::GetWorkAreaBoundsInScreen() const {
- return native_widget_->GetWorkAreaBoundsInScreen();
-}
-
////////////////////////////////////////////////////////////////////////////////
// Widget, NativeWidgetDelegate implementation:
diff --git a/views/widget/widget.h b/views/widget/widget.h
index b5ba346..dd23dd6 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -565,9 +565,6 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
// TYPE_CONTROL and TYPE_TOOLTIP is not considered top level.
bool is_top_level() const { return is_top_level_; }
- // Returns the bounds of work area in the screen that Widget belongs to.
- gfx::Rect GetWorkAreaBoundsInScreen() const;
-
// Overridden from NativeWidgetDelegate:
virtual bool IsModal() const OVERRIDE;
virtual bool IsDialogBox() const OVERRIDE;