summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-13 01:37:35 +0000
committeroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-13 01:37:35 +0000
commitcaee17863b73aa083656381a918a98e76d93b61f (patch)
tree37621788206406eac0fd880fe31e4639be79164a
parent86da286163563a0c1fd3079e677289b2ebc8a932 (diff)
downloadchromium_src-caee17863b73aa083656381a918a98e76d93b61f.zip
chromium_src-caee17863b73aa083656381a918a98e76d93b61f.tar.gz
chromium_src-caee17863b73aa083656381a918a98e76d93b61f.tar.bz2
Relanding 100792
Use TabContentsViewViews for RenderWidgetHostViweViews. * Removed TabContentsViewTouch. * Changed so that mouse and resize event goes through NativeWidgetViews so that NativeTabContentsViewViews can invoke NativeTabContentsViewDelegates. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=100792 Review URL: http://codereview.chromium.org/7460001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100834 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.cc83
-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, 289 insertions, 770 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 1df60b6..5a42dde 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -76,9 +76,7 @@
#include "chrome/browser/crash_handler_host_linux.h"
#endif
-#if defined(TOUCH_UI)
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
-#elif defined(TOOLKIT_VIEWS)
+#if 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"
@@ -137,9 +135,7 @@ content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
TabContentsView* ChromeContentBrowserClient::CreateTabContentsView(
TabContents* tab_contents) {
-#if defined(TOUCH_UI)
- return new TabContentsViewTouch(tab_contents);
-#elif defined(TOOLKIT_VIEWS)
+#if 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 6396c4b..2fac61d 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_views.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc
@@ -194,7 +194,8 @@ void RenderWidgetHostViewViews::SetSize(const gfx::Size& size) {
}
void RenderWidgetHostViewViews::SetBounds(const gfx::Rect& rect) {
- NOTIMPLEMENTED();
+ // TODO(oshima): chromeos/touch doesn't allow moving window.
+ SetSize(rect.size());
}
gfx::NativeView RenderWidgetHostViewViews::GetNativeView() const {
@@ -748,7 +749,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 (GetInnerNativeView()->window) {
+ if (IsReadyToPaint()) {
#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 e81b48d..6c7b8a9 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 views::View.
+ // Overridden from views::View.
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void OnFocus() OVERRIDE;
virtual void OnBlur() OVERRIDE;
@@ -210,10 +210,8 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView,
void UpdateTouchSelectionController();
#if defined(TOOLKIT_USES_GTK)
- // 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;
+ // Returns true if the RWHV is ready to paint the content.
+ bool IsReadyToPaint();
#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 e8437a7..f253314 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,25 +69,26 @@ gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
}
#endif
-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;
+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;
}
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 (!GetInnerNativeView() || !GetInnerNativeView()->window)
+ if (!IsReadyToPaint())
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 f2026a8..01cc99b 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_touch.h"
+#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.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 25a9912..2b7b4c1 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 TabContentsViewTouch;
+class TabContentsViewViews;
#elif defined(TOOLKIT_VIEWS)
class NativeTabContentsViewGtk;
#else
@@ -51,7 +51,7 @@ class ConstrainedWindowGtkDelegate {
class ConstrainedWindowGtk : public ConstrainedWindow {
public:
#if defined(TOUCH_UI)
- typedef TabContentsViewTouch TabContentsViewType;
+ typedef TabContentsViewViews 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 97f78a9..bb9f85c 100644
--- a/chrome/browser/ui/touch/keyboard/keyboard_manager.cc
+++ b/chrome/browser/ui/touch/keyboard/keyboard_manager.cc
@@ -13,12 +13,10 @@
#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 4555bd1..6f90426 100644
--- a/chrome/browser/ui/views/dom_view.cc
+++ b/chrome/browser/ui/views/dom_view.cc
@@ -6,12 +6,10 @@
#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"
-
-#if defined(TOUCH_UI)
-#include "chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h"
-#endif
+#include "views/widget/native_widget_views.h"
// static
const char DOMView::kViewClassName[] =
@@ -81,9 +79,13 @@ void DOMView::ViewHierarchyChanged(bool is_add, views::View* parent,
}
void DOMView::AttachTabContents() {
-#if defined(TOUCH_UI)
- AttachToView(static_cast<TabContentsViewTouch*>(tab_contents_->view()));
-#else
- Attach(tab_contents_->GetNativeView());
-#endif
+ 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());
+ }
}
diff --git a/chrome/browser/ui/views/find_bar_host_gtk.cc b/chrome/browser/ui/views/find_bar_host_gtk.cc
index 1600e34..ca516d6 100644
--- a/chrome/browser/ui/views/find_bar_host_gtk.cc
+++ b/chrome/browser/ui/views/find_bar_host_gtk.cc
@@ -7,13 +7,10 @@
#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();
@@ -23,12 +20,7 @@ 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 e836183..7705344 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,7 +13,6 @@
#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:
@@ -63,7 +62,6 @@ 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.
@@ -73,9 +71,6 @@ void NativeTabContentsContainerGtk::TabContentsFocused(
return;
}
focus_manager->SetFocusedView(this);
-#else
- // no native views in TOUCH_UI, so don't steal the focus
-#endif
}
////////////////////////////////////////////////////////////////////////////////
@@ -147,8 +142,7 @@ void NativeTabContentsContainerGtk::GetAccessibleState(
// static
NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer(
TabContentsContainer* container) {
- if (views::Widget::IsPureViews() &&
- views::ViewsDelegate::views_delegate->GetDefaultParentView())
+ if (views::Widget::IsPureViews())
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 6a2bec9..1849428 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,12 +66,9 @@ views::View* NativeTabContentsContainerViews::GetView() {
void NativeTabContentsContainerViews::TabContentsFocused(
TabContents* tab_contents) {
- views::FocusManager* focus_manager = GetFocusManager();
- if (!focus_manager) {
- NOTREACHED();
- return;
- }
- focus_manager->SetFocusedView(this);
+ // This is called from RWHVViews::OnFocus, which means
+ // the focus manager already set focus to RWHVViews, so don't
+ // Update focus manager.
}
////////////////////////////////////////////////////////////////////////////////
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 6045638..750dc45 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,7 +12,6 @@
#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"
////////////////////////////////////////////////////////////////////////////////
@@ -157,8 +156,7 @@ gfx::NativeViewAccessible
// static
NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer(
TabContentsContainer* container) {
- if (views::Widget::IsPureViews() &&
- views::ViewsDelegate::views_delegate->GetDefaultParentView())
+ if (views::Widget::IsPureViews())
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 f0566e6..ee2f37f 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,7 +15,6 @@
#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;
@@ -262,8 +261,7 @@ void NativeTabContentsViewGtk::PositionConstrainedWindows(
// static
NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView(
internal::NativeTabContentsViewDelegate* delegate) {
- if (views::Widget::IsPureViews() &&
- views::ViewsDelegate::views_delegate->GetDefaultParentView())
+ if (views::Widget::IsPureViews())
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 9ed403e..d143b61 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,6 +25,33 @@ 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() {
@@ -88,3 +115,11 @@ 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 feacb03..f7961ba 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,6 +11,10 @@
class TabContents;
+namespace views {
+class MouseEvent;
+}
+
class NativeTabContentsViewViews : public views::NativeWidgetViews,
public NativeTabContentsView {
public:
@@ -19,6 +23,11 @@ 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 efd7593..e7fa35a 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,6 +6,7 @@
#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"
@@ -16,13 +17,6 @@
#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:
@@ -37,17 +31,9 @@ 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 1777479..67a3159 100644
--- a/chrome/browser/ui/views/tab_contents/tab_contents_container.h
+++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.h
@@ -16,10 +16,11 @@
// 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.
-#if defined(TOUCH_UI)
-#include "chrome/browser/ui/views/tab_contents/tab_contents_container_views.h"
-#else
+
+// TODO(oshima): Rename tab_contents_container_native to tab_contents_container.
+// TODO(oshima): Figure out if we can consolidate
+// native_tab_contents_containers.
+
#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 28ce5f2..69633aa 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,6 +4,10 @@
#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"
@@ -69,6 +73,48 @@ 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 da28347..528b5f0 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,6 +49,9 @@ 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
deleted file mode 100644
index 1e13c51..0000000
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_touch.cc
+++ /dev/null
@@ -1,430 +0,0 @@
-// 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
deleted file mode 100644
index 6397668..0000000
--- a/chrome/browser/ui/views/tab_contents/tab_contents_view_touch.h
+++ /dev/null
@@ -1,160 +0,0 @@
-// 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 0eab11bb..117ba35 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,10 +52,17 @@ 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_ = GetFocusManager();
+ focus_manager_ = Widget::GetFocusManager();
CHECK(native_tab_contents_view_);
native_tab_contents_view_->Unparent();
}
@@ -164,10 +171,15 @@ void TabContentsViewViews::Focus() {
}
RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
- views::FocusManager* focus_manager = GetFocusManager();
- if (focus_manager)
- focus_manager->FocusNativeView(rwhv ? rwhv->GetNativeView()
- : GetNativeView());
+ 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());
+ }
}
void TabContentsViewViews::SetInitialFocus() {
@@ -254,7 +266,8 @@ void TabContentsViewViews::GotFocus() {
}
void TabContentsViewViews::TakeFocus(bool reverse) {
- if (!tab_contents_->delegate()->TakeFocus(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
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 b41f796..fa29b6a 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,6 +13,7 @@
#include "content/browser/tab_contents/tab_contents_view.h"
#include "views/widget/widget.h"
+class ConstrainedWindowGtk;
class NativeTabContentsView;
class RenderViewContextMenuViews;
class SadTabView;
@@ -39,6 +40,11 @@ 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 1f410ea..44b5433 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3426,12 +3426,8 @@
'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',
@@ -3979,9 +3975,6 @@
['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.*'],
],
}],
@@ -3997,7 +3990,6 @@
['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'],
@@ -4828,8 +4820,6 @@
# 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
@@ -4837,9 +4827,6 @@
# ['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 64f4795..e9d8f61 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -258,9 +258,7 @@ int MenuButton::GetMaximumScreenXCoordinate() {
return 0;
}
- gfx::Rect monitor_bounds =
- gfx::Screen::GetMonitorWorkAreaNearestWindow(
- GetWidget()->GetTopLevelWidget()->GetNativeView());
+ gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
return monitor_bounds.right() - 1;
}
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 7cb5892..d1eeb23 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -1333,6 +1333,10 @@ bool NativeWidgetGtk::ConvertPointFromAncestor(
return false;
}
+gfx::Rect NativeWidgetGtk::GetWorkAreaBoundsInScreen() const {
+ return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView());
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetGtk, protected:
@@ -2134,22 +2138,20 @@ bool Widget::ConvertRect(const Widget* source,
DCHECK(target);
DCHECK(rect);
- GtkWidget* source_widget = source->GetNativeView();
- GtkWidget* target_widget = target->GetNativeView();
- if (source_widget == target_widget)
- return true;
+ // TODO(oshima): Add check if source and target belongs to the same
+ // screen.
- if (!source_widget || !target_widget)
+ if (source == target)
+ return true;
+ if (!source || !target)
return false;
- 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;
+ gfx::Point source_point = source->GetWindowScreenBounds().origin();
+ gfx::Point target_point = target->GetWindowScreenBounds().origin();
+
+ rect->set_origin(
+ source_point.Subtract(target_point).Add(rect->origin()));
+ return true;
}
namespace internal {
diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h
index eb5ec4a..fed434f 100644
--- a/views/widget/native_widget_gtk.h
+++ b/views/widget/native_widget_gtk.h
@@ -220,6 +220,7 @@ 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 dbeab12..f47c5ac 100644
--- a/views/widget/native_widget_private.h
+++ b/views/widget/native_widget_private.h
@@ -204,6 +204,7 @@ 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 0b60850..500c614 100644
--- a/views/widget/native_widget_view.cc
+++ b/views/widget/native_widget_view.cc
@@ -5,10 +5,6 @@
#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 {
@@ -67,7 +63,7 @@ void NativeWidgetView::ViewHierarchyChanged(bool is_add,
}
void NativeWidgetView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
- delegate()->OnNativeWidgetSizeChanged(size());
+ native_widget_->OnBoundsChanged(bounds(), previous_bounds);
}
void NativeWidgetView::OnPaint(gfx::Canvas* canvas) {
@@ -79,46 +75,15 @@ gfx::NativeCursor NativeWidgetView::GetCursor(const MouseEvent& event) {
}
bool NativeWidgetView::OnMousePressed(const MouseEvent& 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);
+ return native_widget_->OnMouseEvent(event);
}
bool NativeWidgetView::OnMouseDragged(const MouseEvent& event) {
- return delegate()->OnMouseEvent(event);
+ return native_widget_->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseReleased(const MouseEvent& event) {
- delegate()->OnMouseEvent(event);
+ native_widget_->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseCaptureLost() {
@@ -126,15 +91,15 @@ void NativeWidgetView::OnMouseCaptureLost() {
}
void NativeWidgetView::OnMouseMoved(const MouseEvent& event) {
- delegate()->OnMouseEvent(event);
+ native_widget_->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseEntered(const MouseEvent& event) {
- delegate()->OnMouseEvent(event);
+ native_widget_->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseExited(const MouseEvent& event) {
- delegate()->OnMouseEvent(event);
+ native_widget_->OnMouseEvent(event);
}
ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) {
@@ -150,7 +115,7 @@ bool NativeWidgetView::OnKeyReleased(const KeyEvent& event) {
}
bool NativeWidgetView::OnMouseWheel(const MouseWheelEvent& event) {
- return delegate()->OnMouseEvent(event);
+ return native_widget_->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 44f2d9d..3f0c685 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -18,6 +18,10 @@
#include "views/ime/mock_input_method.h"
#endif
+#if defined(OS_LINUX)
+#include "views/window/hit_test.h"
+#endif
+
namespace views {
////////////////////////////////////////////////////////////////////////////////
@@ -30,7 +34,6 @@ 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) {
}
@@ -95,6 +98,18 @@ 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) {
@@ -102,11 +117,13 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
always_on_top_ = params.keep_on_top;
View* parent_view = NULL;
if (params.parent_widget) {
- hosting_widget_ = params.parent_widget;
- parent_view = hosting_widget_->GetChildViewParent();
- } else {
+ parent_view = params.parent_widget->GetChildViewParent();
+ } else if (ViewsDelegate::views_delegate &&
+ ViewsDelegate::views_delegate->GetDefaultParentView()) {
parent_view = ViewsDelegate::views_delegate->GetDefaultParentView();
- hosting_widget_ = parent_view->GetWidget();
+ } else if (params.parent) {
+ Widget* widget = Widget::GetWidgetForNativeView(params.parent);
+ parent_view = widget->GetChildViewParent();
}
view_ = new internal::NativeWidgetView(this);
@@ -124,7 +141,8 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET)
view_->set_delete_native_widget(false);
- parent_view->AddChildView(view_);
+ if (parent_view)
+ parent_view->AddChildView(view_);
// TODO(beng): SetInitParams().
}
@@ -165,7 +183,8 @@ Widget* NativeWidgetViews::GetTopLevelWidget() {
// view_ has already been unset.
if (!view_)
return GetWidget();
- if (view_->parent() == ViewsDelegate::views_delegate->GetDefaultParentView())
+ if (ViewsDelegate::views_delegate &&
+ view_->parent() == ViewsDelegate::views_delegate->GetDefaultParentView())
return GetWidget();
// During Widget destruction, this function may be called after |view_| is
// detached from a Widget, at which point this NativeWidget's Widget becomes
@@ -176,11 +195,11 @@ Widget* NativeWidgetViews::GetTopLevelWidget() {
}
const ui::Compositor* NativeWidgetViews::GetCompositor() const {
- return hosting_widget_->GetCompositor();
+ return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL;
}
ui::Compositor* NativeWidgetViews::GetCompositor() {
- return hosting_widget_->GetCompositor();
+ return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL;
}
void NativeWidgetViews::MarkLayerDirty() {
@@ -470,7 +489,7 @@ void NativeWidgetViews::RunShellDrag(View* view,
}
void NativeWidgetViews::SchedulePaintInRect(const gfx::Rect& rect) {
- view_->SchedulePaintInternal(rect);
+ view_->SchedulePaintInRect(rect);
}
void NativeWidgetViews::SetCursor(gfx::NativeCursor cursor) {
@@ -507,6 +526,13 @@ 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:
@@ -525,4 +551,41 @@ 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 eaa2804..b0c2ea3 100644
--- a/views/widget/native_widget_views.h
+++ b/views/widget/native_widget_views.h
@@ -47,7 +47,12 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate {
internal::NativeWidgetDelegate* delegate() const { return delegate_; }
protected:
- friend class NativeWidgetView;
+ 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);
// Overridden from internal::NativeWidgetPrivate:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
@@ -130,6 +135,7 @@ 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;
@@ -141,6 +147,8 @@ 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_;
@@ -159,8 +167,6 @@ 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 23ef015..b75a4a9 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -1092,6 +1092,10 @@ 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 967ed85..43b4a76 100644
--- a/views/widget/native_widget_win.h
+++ b/views/widget/native_widget_win.h
@@ -266,6 +266,7 @@ 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 8ed6c8d..39e7e8b 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -604,7 +604,7 @@ ThemeProvider* Widget::GetThemeProvider() const {
}
FocusManager* Widget::GetFocusManager() {
- Widget* toplevel_widget = GetTopLevelWidget();
+ const Widget* toplevel_widget = GetTopLevelWidget();
return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL;
}
@@ -803,6 +803,10 @@ 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 dd23dd6..b5ba346 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -565,6 +565,9 @@ 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;