summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/views/SConscript14
-rw-r--r--chrome/views/background.cc10
-rw-r--r--chrome/views/focus_manager.h15
-rw-r--r--chrome/views/root_view.cc129
-rw-r--r--chrome/views/root_view.h12
-rw-r--r--chrome/views/root_view_gtk.cc17
-rw-r--r--chrome/views/root_view_win.cc82
-rw-r--r--chrome/views/view.cc112
-rw-r--r--chrome/views/view.h8
-rw-r--r--chrome/views/view_gtk.cc56
-rw-r--r--chrome/views/view_win.cc91
-rw-r--r--chrome/views/views.vcproj8
-rw-r--r--chrome/views/widget.h4
13 files changed, 171 insertions, 387 deletions
diff --git a/chrome/views/SConscript b/chrome/views/SConscript
index a15a0e5..7e4596a 100644
--- a/chrome/views/SConscript
+++ b/chrome/views/SConscript
@@ -92,18 +92,7 @@ input_files = [
'window_delegate.cc',
]
-if env.Bit('windows'):
- input_files += [
- "root_view_win.cc",
- "view_win.cc"
- ]
-
if env.Bit('linux'):
- input_files += [
- "root_view_gtk.cc",
- "view_gtk.cc"
- ]
-
# TODO(port): Port to Linux.
remove_files = [
'accelerator.cc',
@@ -111,6 +100,7 @@ if env.Bit('linux'):
'accessibility/accessible_wrapper.cc',
'accessibility/view_accessibility.cc',
'aero_tooltip_manager.cc',
+ 'background.cc',
'base_button.cc',
'bitmap_scroll_bar.cc',
'button.cc',
@@ -140,6 +130,7 @@ if env.Bit('linux'):
'painter.cc',
'radio_button.cc',
'resize_corner.cc',
+ 'root_view.cc',
'root_view_drop_target.cc',
'scroll_view.cc',
'separator.cc',
@@ -151,6 +142,7 @@ if env.Bit('linux'):
'throbber.cc',
'tooltip_manager.cc',
'tree_view.cc',
+ 'view.cc',
'widget_win.cc',
'window.cc',
'window_delegate.cc',
diff --git a/chrome/views/background.cc b/chrome/views/background.cc
index 056e511..1aa631e 100644
--- a/chrome/views/background.cc
+++ b/chrome/views/background.cc
@@ -59,24 +59,16 @@ class BackgroundPainter : public Background {
DISALLOW_EVIL_CONSTRUCTORS(BackgroundPainter);
};
-Background::Background()
-#if defined(OS_WIN)
- : native_control_brush_(NULL)
-#endif
-{
+Background::Background() : native_control_brush_(NULL) {
}
Background::~Background() {
-#if defined(OS_WIN)
DeleteObject(native_control_brush_);
-#endif
}
void Background::SetNativeControlColor(SkColor color) {
-#if defined(OS_WIN)
DeleteObject(native_control_brush_);
native_control_brush_ = CreateSolidBrush(skia::SkColorToCOLORREF(color));
-#endif
}
//static
diff --git a/chrome/views/focus_manager.h b/chrome/views/focus_manager.h
index b2de656..4fcd1ce 100644
--- a/chrome/views/focus_manager.h
+++ b/chrome/views/focus_manager.h
@@ -5,9 +5,7 @@
#ifndef CHROME_VIEWS_FOCUS_MANAGER_H__
#define CHROME_VIEWS_FOCUS_MANAGER_H__
-#if defined(OS_WIN)
#include <windows.h>
-#endif
#include <vector>
#include <map>
@@ -138,10 +136,8 @@ class KeystrokeListener {
public:
// If this returns true, then the component handled the keystroke and ate
// it.
-#if defined(OS_WIN)
virtual bool ProcessKeyDown(HWND window, UINT message, WPARAM wparam,
LPARAM lparam) = 0;
-#endif
};
// This interface should be implemented by classes that want to be notified when
@@ -153,7 +149,6 @@ class FocusChangeListener {
class FocusManager : public NotificationObserver {
public:
-#if defined(OS_WIN)
// Creates a FocusManager for the specified window. Top level windows
// must invoked this when created.
// The RootView specified should be the top RootView of the window.
@@ -172,6 +167,7 @@ class FocusManager : public NotificationObserver {
static FocusManager* GetFocusManager(HWND window);
+
// Message handlers (for messages received from registered windows).
// Should return true if the message should be forwarded to the window
// original proc function, false otherwise.
@@ -185,7 +181,6 @@ class FocusManager : public NotificationObserver {
// OnPostActivate is called after WM_ACTIVATE has been propagated to the
// DefWindowProc.
bool OnPostActivate(HWND window, int activation_state, int minimized_state);
-#endif
// Returns true is the specified is part of the hierarchy of the window
// associated with this FocusManager.
@@ -207,21 +202,17 @@ class FocusManager : public NotificationObserver {
// Note that this does not change the currently focused view.
void ClearHWNDFocus();
-#if defined(OS_WIN)
// Focus the specified |hwnd| without changing the focused view.
void FocusHWND(HWND hwnd);
-#endif
// Validates the focused view, clearing it if the window it belongs too is not
// attached to the window hierarchy anymore.
void ValidateFocusedView();
-#if defined(OS_WIN)
// Returns the view associated with the specified window if any.
// If |look_in_parents| is true, it goes up the window parents until it find
// a view.
static View* GetViewForWindow(HWND window, bool look_in_parents);
-#endif
// Stores and restores the focused view. Used when the window becomes
// active/inactive.
@@ -288,9 +279,7 @@ class FocusManager : public NotificationObserver {
const Accelerator& accelerator) const;
private:
-#if defined(OS_WIN)
explicit FocusManager(HWND root, RootView* root_view);
-#endif
~FocusManager();
// Returns the next focusable view.
@@ -318,10 +307,8 @@ class FocusManager : public NotificationObserver {
// had focus.
int stored_focused_view_storage_id_;
-#if defined(OS_WIN)
// The window associated with this focus manager.
HWND root_;
-#endif
// Used to allow setting the focus on an HWND without changing the currently
// focused view.
diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc
index 4029e66..ac59d3f 100644
--- a/chrome/views/root_view.cc
+++ b/chrome/views/root_view.cc
@@ -6,16 +6,12 @@
#include <algorithm>
-#if defined(OS_WIN)
#include "base/base_drag_source.h"
-#endif
#include "base/logging.h"
#include "base/message_loop.h"
#include "chrome/common/drag_drop_types.h"
#include "chrome/common/gfx/chrome_canvas.h"
-#if defined(OS_WIN)
#include "chrome/views/root_view_drop_target.h"
-#endif
#include "chrome/views/widget.h"
namespace views {
@@ -56,22 +52,20 @@ const char RootView::kViewClassName[] = "chrome/views/RootView";
/////////////////////////////////////////////////////////////////////////////
RootView::RootView(Widget* widget)
- : mouse_pressed_handler_(NULL),
+ : widget_(widget),
+ mouse_pressed_handler_(NULL),
mouse_move_handler_(NULL),
- widget_(widget),
- invalid_rect_urgent_(false),
- pending_paint_task_(NULL),
- paint_task_needed_(false),
- explicit_mouse_handler_(false),
-#if defined(OS_WIN)
+ explicit_mouse_handler_(FALSE),
previous_cursor_(NULL),
-#endif
default_keyboard_hander_(NULL),
- focus_listener_(NULL),
focus_on_mouse_pressed_(false),
ignore_set_focus_calls_(false),
+ focus_listener_(NULL),
focus_traversable_parent_(NULL),
focus_traversable_parent_view_(NULL),
+ invalid_rect_urgent_(false),
+ pending_paint_task_(NULL),
+ paint_task_needed_(false),
drag_view_(NULL)
#ifndef NDEBUG
,
@@ -149,13 +143,9 @@ void RootView::ProcessPaint(ChromeCanvas* canvas) {
ScopedProcessingPaint processing_paint(&is_processing_paint_);
#endif
-#if defined(OS_WIN)
// Clip the invalid rect to our bounds. If a view is in a scrollview
// it could be a lot larger
invalid_rect_ = gfx::Rect(GetScheduledPaintRectConstrainedToSize());
-#else
- NOTIMPLEMENTED();
-#endif
if (invalid_rect_.IsEmpty())
return;
@@ -209,6 +199,13 @@ const gfx::Rect& RootView::GetScheduledPaintRect() {
return invalid_rect_;
}
+RECT RootView::GetScheduledPaintRectConstrainedToSize() {
+ if (invalid_rect_.IsEmpty())
+ return invalid_rect_.ToRECT();
+
+ return invalid_rect_.Intersect(GetLocalBounds(true)).ToRECT();
+}
+
/////////////////////////////////////////////////////////////////////////////
//
// RootView - tree
@@ -231,12 +228,8 @@ void RootView::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
mouse_pressed_handler_ = NULL;
}
-#if defined(OS_WIN)
if (drop_target_.get())
drop_target_->ResetTargetViewIfEquals(child);
-#else
- NOTIMPLEMENTED();
-#endif
if (mouse_move_handler_ == child) {
mouse_move_handler_ = NULL;
@@ -318,14 +311,10 @@ bool RootView::OnMousePressed(const MouseEvent& e) {
mouse_pressed_handler_ = NULL;
if (focus_on_mouse_pressed_) {
-#if defined(OS_WIN)
HWND hwnd = GetWidget()->GetHWND();
if (::GetFocus() != hwnd) {
::SetFocus(hwnd);
}
-#else
- NOTIMPLEMENTED();
-#endif
}
return hit_disabled_view;
}
@@ -393,6 +382,23 @@ void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) {
}
}
+void RootView::UpdateCursor(const MouseEvent& e) {
+ View *v = GetViewForPoint(e.location());
+
+ if (v && v != this) {
+ gfx::Point l(e.location());
+ View::ConvertPointToView(this, v, &l);
+ HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y());
+ if (cursor) {
+ ::SetCursor(cursor);
+ return;
+ }
+ }
+ if (previous_cursor_) {
+ SetCursor(previous_cursor_);
+ }
+}
+
void RootView::OnMouseMoved(const MouseEvent& e) {
View *v = GetViewForPoint(e.location());
// Find the first enabled view.
@@ -421,7 +427,6 @@ void RootView::OnMouseMoved(const MouseEvent& e) {
0);
mouse_move_handler_->OnMouseMoved(moved_event);
-#if defined(OS_WIN)
HCURSOR cursor = mouse_move_handler_->GetCursorForPoint(
moved_event.GetType(), moved_event.x(), moved_event.y());
if (cursor) {
@@ -430,20 +435,13 @@ void RootView::OnMouseMoved(const MouseEvent& e) {
::SetCursor(previous_cursor_);
previous_cursor_ = NULL;
}
-#else
- NOTIMPLEMENTED();
-#endif
} else if (mouse_move_handler_ != NULL) {
MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0);
mouse_move_handler_->OnMouseExited(exited_event);
-#if defined(OS_WIN)
if (previous_cursor_) {
::SetCursor(previous_cursor_);
previous_cursor_ = NULL;
}
-#else
- NOTIMPLEMENTED();
-#endif
}
}
@@ -462,25 +460,15 @@ void RootView::SetMouseHandler(View *new_mh) {
}
void RootView::OnWidgetCreated() {
-#if defined(OS_WIN)
DCHECK(!drop_target_.get());
drop_target_ = new RootViewDropTarget(this);
-#else
- // TODO(port): Port RootViewDropTarget and this goes away.
- NOTIMPLEMENTED();
-#endif
}
void RootView::OnWidgetDestroyed() {
-#if defined(OS_WIN)
if (drop_target_.get()) {
RevokeDragDrop(GetWidget()->GetHWND());
drop_target_ = NULL;
}
-#else
- // TODO(port): Port RootViewDropTarget and this goes away.
- NOTIMPLEMENTED();
-#endif
widget_ = NULL;
}
@@ -499,7 +487,6 @@ void RootView::SetFocusListener(FocusListener* listener) {
void RootView::FocusView(View* view) {
if (view != GetFocusedView()) {
-#if defined(OS_WIN)
FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager) << "No Focus Manager for Window " <<
(GetWidget() ? GetWidget()->GetHWND() : 0);
@@ -511,10 +498,6 @@ void RootView::FocusView(View* view) {
if (focus_listener_)
focus_listener_->FocusChanged(prev_focused_view, view);
-#else
- // TODO(port): Port the focus manager and this goes away.
- NOTIMPLEMENTED();
-#endif
}
}
@@ -816,7 +799,6 @@ void RootView::ProcessKeyEvent(const KeyEvent& event) {
bool consumed = false;
if (GetFocusedView()) {
-#if defined(OS_WIN)
// Special case to handle right-click context menus triggered by the
// keyboard.
if ((event.GetCharacter() == VK_APPS) ||
@@ -828,10 +810,6 @@ void RootView::ProcessKeyEvent(const KeyEvent& event) {
return;
}
}
-#else
- // TODO(port): The above block needs the VK_* refactored out.
- NOTIMPLEMENTED();
-#endif
for (v = GetFocusedView();
v && v != this && !consumed; v = v->GetParent()) {
@@ -930,12 +908,39 @@ void RootView::ClearPaintRect() {
paint_task_needed_ = false;
}
+void RootView::OnPaint(HWND hwnd) {
+ RECT original_dirty_region = GetScheduledPaintRectConstrainedToSize();
+ if (!IsRectEmpty(&original_dirty_region)) {
+ // Invoke InvalidateRect so that the dirty region of the window includes the
+ // region we need to paint. If we didn't do this and the region didn't
+ // include the dirty region, ProcessPaint would incorrectly mark everything
+ // as clean. This can happen if a WM_PAINT is generated by the system before
+ // the InvokeLater schedule by RootView is processed.
+ InvalidateRect(hwnd, &original_dirty_region, FALSE);
+ }
+ ChromeCanvasPaint canvas(hwnd);
+ if (!canvas.isEmpty()) {
+ const PAINTSTRUCT& ps = canvas.paintStruct();
+ SchedulePaint(gfx::Rect(ps.rcPaint), false);
+ if (NeedsPainting(false))
+ ProcessPaint(&canvas);
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////
//
// RootView - accessibility
//
/////////////////////////////////////////////////////////////////////////////
+bool RootView::GetAccessibleRole(VARIANT* role) {
+ DCHECK(role);
+
+ role->vt = VT_I4;
+ role->lVal = ROLE_SYSTEM_APPLICATION;
+ return true;
+}
+
bool RootView::GetAccessibleName(std::wstring* name) {
if (!accessible_name_.empty()) {
*name = accessible_name_;
@@ -948,6 +953,24 @@ void RootView::SetAccessibleName(const std::wstring& name) {
accessible_name_.assign(name);
}
+void RootView::StartDragForViewFromMouseEvent(
+ View* view,
+ IDataObject* data,
+ int operation) {
+ drag_view_ = view;
+ scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
+ DWORD effects;
+ DoDragDrop(data, drag_source,
+ DragDropTypes::DragOperationToDropEffect(operation), &effects);
+ // If the view is removed during the drag operation, drag_view_ is set to
+ // NULL.
+ if (drag_view_ == view) {
+ View* drag_view = drag_view_;
+ drag_view_ = NULL;
+ drag_view->OnDragDone();
+ }
+}
+
View* RootView::GetDragView() {
return drag_view_;
}
diff --git a/chrome/views/root_view.h b/chrome/views/root_view.h
index f1a0d89..6c62ba8 100644
--- a/chrome/views/root_view.h
+++ b/chrome/views/root_view.h
@@ -73,10 +73,8 @@ class RootView : public View,
// Invoked by the Widget to discover what rectangle should be painted.
const gfx::Rect& GetScheduledPaintRect();
-#if defined(OS_WIN)
// Returns the region scheduled to paint clipped to the RootViews bounds.
RECT GetScheduledPaintRectConstrainedToSize();
-#endif
// Tree functions
@@ -169,17 +167,13 @@ class RootView : public View,
// to invoke this. This is primarily intended for Widgets.
void ClearPaintRect();
-#if defined(OS_WIN)
// Invoked from the Widget to service a WM_PAINT call.
void OnPaint(HWND hwnd);
-#endif
-#if defined(OS_WIN)
// Returns the MSAA role of the current view. The role is what assistive
// technologies (ATs) use to determine what behavior to expect from a given
// control.
bool GetAccessibleRole(VARIANT* role);
-#endif
// Returns a brief, identifying string, containing a unique, readable name.
bool GetAccessibleName(std::wstring* name);
@@ -254,14 +248,12 @@ class RootView : public View,
// Updates the last_mouse_* fields from e.
void SetMouseLocationAndFlags(const MouseEvent& e);
-#if defined(OS_WIN)
// Starts a drag operation for the specified view. This blocks until done.
// If the view has not been deleted during the drag, OnDragDone is invoked
// on the view.
void StartDragForViewFromMouseEvent(View* view,
IDataObject* data,
int operation);
-#endif
// If a view is dragging, this returns it. Otherwise returns NULL.
View* GetDragView();
@@ -292,10 +284,8 @@ class RootView : public View,
// true if mouse_handler_ has been explicitly set
bool explicit_mouse_handler_;
-#if defined(OS_WIN)
// Previous cursor
HCURSOR previous_cursor_;
-#endif
// Default keyboard handler
View* default_keyboard_hander_;
@@ -327,10 +317,8 @@ class RootView : public View,
// wrapped inside native components, and is used for the focus traversal.
View* focus_traversable_parent_view_;
-#if defined(OS_WIN)
// Handles dnd for us.
scoped_refptr<RootViewDropTarget> drop_target_;
-#endif
// Storage of strings needed for accessibility.
std::wstring accessible_name_;
diff --git a/chrome/views/root_view_gtk.cc b/chrome/views/root_view_gtk.cc
deleted file mode 100644
index 4615a82..0000000
--- a/chrome/views/root_view_gtk.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2006-2008 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/views/root_view.h"
-
-namespace views {
-
-// TODO(port): Port GetScheduledPaintRectConstrainedToSize() to not use RECT.
-
-void RootView::UpdateCursor(const MouseEvent& e) {
- NOTIMPLEMENTED();
-}
-
-// TODO(port): Port OnPaint() to not use HWNDs in its public interface.
-
-}
diff --git a/chrome/views/root_view_win.cc b/chrome/views/root_view_win.cc
deleted file mode 100644
index a843f1d..0000000
--- a/chrome/views/root_view_win.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) 2006-2008 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/views/root_view.h"
-
-#include "base/base_drag_source.h"
-#include "chrome/common/drag_drop_types.h"
-#include "chrome/views/root_view_drop_target.h"
-
-namespace views {
-
-RECT RootView::GetScheduledPaintRectConstrainedToSize() {
- if (invalid_rect_.IsEmpty())
- return invalid_rect_.ToRECT();
-
- return invalid_rect_.Intersect(GetLocalBounds(true)).ToRECT();
-}
-
-void RootView::UpdateCursor(const MouseEvent& e) {
- View *v = GetViewForPoint(e.location());
-
- if (v && v != this) {
- gfx::Point l(e.location());
- View::ConvertPointToView(this, v, &l);
- HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y());
- if (cursor) {
- ::SetCursor(cursor);
- return;
- }
- }
- if (previous_cursor_) {
- SetCursor(previous_cursor_);
- }
-}
-
-void RootView::OnPaint(HWND hwnd) {
- RECT original_dirty_region = GetScheduledPaintRectConstrainedToSize();
- if (!IsRectEmpty(&original_dirty_region)) {
- // Invoke InvalidateRect so that the dirty region of the window includes the
- // region we need to paint. If we didn't do this and the region didn't
- // include the dirty region, ProcessPaint would incorrectly mark everything
- // as clean. This can happen if a WM_PAINT is generated by the system before
- // the InvokeLater schedule by RootView is processed.
- InvalidateRect(hwnd, &original_dirty_region, FALSE);
- }
- ChromeCanvasPaint canvas(hwnd);
- if (!canvas.isEmpty()) {
- const PAINTSTRUCT& ps = canvas.paintStruct();
- SchedulePaint(gfx::Rect(ps.rcPaint), false);
- if (NeedsPainting(false))
- ProcessPaint(&canvas);
- }
-}
-
-bool RootView::GetAccessibleRole(VARIANT* role) {
- DCHECK(role);
-
- role->vt = VT_I4;
- role->lVal = ROLE_SYSTEM_APPLICATION;
- return true;
-}
-
-void RootView::StartDragForViewFromMouseEvent(
- View* view,
- IDataObject* data,
- int operation) {
- drag_view_ = view;
- scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
- DWORD effects;
- DoDragDrop(data, drag_source,
- DragDropTypes::DragOperationToDropEffect(operation), &effects);
- // If the view is removed during the drag operation, drag_view_ is set to
- // NULL.
- if (drag_view_ == view) {
- View* drag_view = drag_view_;
- drag_view_ = NULL;
- drag_view->OnDragDone();
- }
-}
-
-}
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index e65a0c9..7ace91d 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -16,15 +16,16 @@
#include "base/string_util.h"
#include "chrome/common/drag_drop_types.h"
#include "chrome/common/gfx/chrome_canvas.h"
+#include "chrome/common/gfx/path.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/common/os_exchange_data.h"
+#include "chrome/views/accessibility/accessible_wrapper.h"
#include "chrome/views/background.h"
+#include "chrome/views/border.h"
#include "chrome/views/layout_manager.h"
#include "chrome/views/root_view.h"
-#include "chrome/views/widget.h"
-#if defined(OS_WIN)
#include "chrome/views/tooltip_manager.h"
-#include "chrome/views/accessibility/accessible_wrapper.h"
-#endif
+#include "chrome/views/widget.h"
#include "SkShader.h"
namespace views {
@@ -69,22 +70,20 @@ class RestoreFocusTask : public Task {
View::View()
: id_(0),
group_(-1),
- enabled_(true),
- focusable_(false),
bounds_(0,0,0,0),
parent_(NULL),
- should_restore_focus_(false),
+ enabled_(true),
is_visible_(true),
+ focusable_(false),
+ accessibility_(NULL),
is_parent_owned_(true),
notify_when_visible_bounds_in_root_changes_(false),
registered_for_visible_bounds_notification_(false),
next_focusable_view_(NULL),
previous_focusable_view_(NULL),
+ should_restore_focus_(false),
restore_focus_view_task_(NULL),
context_menu_controller_(NULL),
-#if defined(OS_WIN)
- accessibility_(NULL),
-#endif
drag_controller_(NULL),
ui_mirroring_is_enabled_for_rtl_languages_(true),
flip_canvas_on_paint_for_rtl_ui_(false) {
@@ -177,6 +176,7 @@ gfx::Size View::GetMinimumSize() {
int View::GetHeightForWidth(int w) {
if (layout_manager_.get())
return layout_manager_->GetPreferredHeightForWidth(this, w);
+
return GetPreferredSize().height();
}
@@ -281,7 +281,20 @@ void View::SetFocusable(bool focusable) {
focusable_ = focusable;
}
+FocusManager* View::GetFocusManager() {
+ Widget* widget = GetWidget();
+ if (!widget)
+ return NULL;
+
+ HWND hwnd = widget->GetHWND();
+ if (!hwnd)
+ return NULL;
+
+ return FocusManager::GetFocusManager(hwnd);
+}
+
bool View::HasFocus() {
+ RootView* root_view = GetRootView();
FocusManager* focus_manager = GetFocusManager();
if (focus_manager)
return focus_manager->GetFocusedView() == this;
@@ -495,6 +508,7 @@ void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) {
// from mouse released.
gfx::Point location(e.location());
ConvertPointToScreen(this, &location);
+ ContextMenuController* context_menu_controller = context_menu_controller_;
OnMouseReleased(e, canceled);
ShowContextMenu(location.x(), location.y(), true);
} else {
@@ -503,6 +517,17 @@ void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) {
// WARNING: we may have been deleted.
}
+void View::DoDrag(const MouseEvent& e, int press_x, int press_y) {
+ scoped_refptr<OSExchangeData> data = new OSExchangeData;
+ WriteDragData(press_x, press_y, data.get());
+
+ // Message the RootView to do the drag and drop. That way if we're removed
+ // the RootView can detect it and avoid calling us back.
+ RootView* root_view = GetRootView();
+ root_view->StartDragForViewFromMouseEvent(
+ this, data, GetDragOperations(press_x, press_y));
+}
+
void View::AddChildView(View* v) {
AddChildView(static_cast<int>(child_views_.size()), v, false);
}
@@ -1020,6 +1045,19 @@ void View::UnregisterAccelerators() {
/////////////////////////////////////////////////////////////////////////////
//
+// View - accessibility
+//
+/////////////////////////////////////////////////////////////////////////////
+
+AccessibleWrapper* View::GetAccessibleWrapper() {
+ if (accessibility_.get() == NULL) {
+ accessibility_.reset(new AccessibleWrapper(this));
+ }
+ return accessibility_.get();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
// View - floating views
//
/////////////////////////////////////////////////////////////////////////////
@@ -1364,6 +1402,26 @@ bool View::IsVisibleInRootView() const {
return false;
}
+bool View::HitTest(const gfx::Point& l) const {
+ if (l.x() >= 0 && l.x() < static_cast<int>(width()) &&
+ l.y() >= 0 && l.y() < static_cast<int>(height())) {
+ if (HasHitTestMask()) {
+ gfx::Path mask;
+ GetHitTestMask(&mask);
+ ScopedHRGN rgn(mask.CreateHRGN());
+ return !!PtInRegion(rgn, l.x(), l.y());
+ }
+ // No mask, but inside our bounds.
+ return true;
+ }
+ // Outside our bounds.
+ return false;
+}
+
+HCURSOR View::GetCursorForPoint(Event::EventType event_type, int x, int y) {
+ return NULL;
+}
+
/////////////////////////////////////////////////////////////////////////////
//
// View - keyboard and focus
@@ -1424,12 +1482,34 @@ int View::OnPerformDrop(const DropTargetEvent& event) {
return DragDropTypes::DRAG_NONE;
}
+static int GetHorizontalDragThreshold() {
+ static int threshold = -1;
+ if (threshold == -1)
+ threshold = GetSystemMetrics(SM_CXDRAG) / 2;
+ return threshold;
+}
+
+static int GetVerticalDragThreshold() {
+ static int threshold = -1;
+ if (threshold == -1)
+ threshold = GetSystemMetrics(SM_CYDRAG) / 2;
+ return threshold;
+}
+
// static
bool View::ExceededDragThreshold(int delta_x, int delta_y) {
return (abs(delta_x) > GetHorizontalDragThreshold() ||
abs(delta_y) > GetVerticalDragThreshold());
}
+void View::Focus() {
+ // Set the native focus to the root view window so it receives the keyboard
+ // messages.
+ FocusManager* focus_manager = GetFocusManager();
+ if (focus_manager)
+ focus_manager->FocusHWND(GetRootView()->GetWidget()->GetHWND());
+}
+
bool View::CanProcessTabKeyEvents() {
return false;
}
@@ -1444,27 +1524,15 @@ bool View::GetTooltipTextOrigin(int x, int y, gfx::Point* loc) {
}
void View::TooltipTextChanged() {
-#if defined(OS_WIN)
Widget* widget = GetWidget();
if (widget && widget->GetTooltipManager())
widget->GetTooltipManager()->TooltipTextChanged(this);
-#else
- // TODO(port): Not actually windows specific; I just haven't ported this part
- // yet.
- NOTIMPLEMENTED();
-#endif
}
void View::UpdateTooltip() {
-#if defined(OS_WIN)
Widget* widget = GetWidget();
if (widget && widget->GetTooltipManager())
widget->GetTooltipManager()->UpdateTooltip();
-#else
- // TODO(port): Not actually windows specific; I just haven't ported this part
- // yet.
- NOTIMPLEMENTED();
-#endif
}
void View::SetParentOwned(bool f) {
diff --git a/chrome/views/view.h b/chrome/views/view.h
index 52f2665..f7d9906 100644
--- a/chrome/views/view.h
+++ b/chrome/views/view.h
@@ -1132,12 +1132,6 @@ class View : public AcceleratorTarget {
int start_y;
};
- // Returns how much the mouse needs to move in one direction to start a
- // drag. These methods cache in a platform-appropriate way. These values are
- // used by the public static method ExceededDragThreshold().
- static int GetHorizontalDragThreshold();
- static int GetVerticalDragThreshold();
-
// RootView invokes these. These in turn invoke the appropriate OnMouseXXX
// method. If a drag is detected, DoDrag is invoked.
bool ProcessMousePressed(const MouseEvent& e, DragInfo* drop_info);
@@ -1308,10 +1302,8 @@ class View : public AcceleratorTarget {
// The menu controller.
ContextMenuController* context_menu_controller_;
-#if defined(OS_WIN)
// The accessibility implementation for this View.
scoped_ptr<AccessibleWrapper> accessibility_;
-#endif
DragController* drag_controller_;
diff --git a/chrome/views/view_gtk.cc b/chrome/views/view_gtk.cc
deleted file mode 100644
index f8b465c..0000000
--- a/chrome/views/view_gtk.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2009 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/views/view.h"
-
-#include "base/logging.h"
-
-namespace views {
-
-FocusManager* View::GetFocusManager() {
- NOTIMPLEMENTED();
- return NULL;
-}
-
-void View::DoDrag(const MouseEvent& e, int press_x, int press_y) {
- NOTIMPLEMENTED();
-}
-
-AccessibleWrapper* View::GetAccessibleWrapper() {
- NOTIMPLEMENTED();
- return NULL;
-}
-
-bool View::HitTest(const gfx::Point& l) const {
- if (l.x() >= 0 && l.x() < static_cast<int>(width()) &&
- l.y() >= 0 && l.y() < static_cast<int>(height())) {
- if (HasHitTestMask()) {
- // TODO(port): port the windows hit test code here. Once that's factored
- // out, we can probably move View::HitTest back into views.cc.
- NOTIMPLEMENTED();
- }
- // No mask, but inside our bounds.
- return true;
- }
- // Outside our bounds.
- return false;
-}
-
-void View::Focus() {
- NOTIMPLEMENTED();
-}
-
-int View::GetHorizontalDragThreshold() {
- static int threshold = -1;
- NOTIMPLEMENTED();
- return threshold;
-}
-
-int View::GetVerticalDragThreshold() {
- static int threshold = -1;
- NOTIMPLEMENTED();
- return threshold;
-}
-
-} // namespace views
diff --git a/chrome/views/view_win.cc b/chrome/views/view_win.cc
deleted file mode 100644
index 190d21f..0000000
--- a/chrome/views/view_win.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) 2009 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/views/view.h"
-
-#include "base/scoped_handle.h"
-#include "base/string_util.h"
-#include "chrome/common/gfx/chrome_canvas.h"
-#include "chrome/common/gfx/path.h"
-#include "chrome/common/os_exchange_data.h"
-#include "chrome/views/accessibility/accessible_wrapper.h"
-#include "chrome/views/border.h"
-#include "chrome/views/root_view.h"
-#include "chrome/views/widget.h"
-
-namespace views {
-
-FocusManager* View::GetFocusManager() {
- Widget* widget = GetWidget();
- if (!widget)
- return NULL;
-
- HWND hwnd = widget->GetHWND();
- if (!hwnd)
- return NULL;
-
- return FocusManager::GetFocusManager(hwnd);
-}
-
-void View::DoDrag(const MouseEvent& e, int press_x, int press_y) {
- scoped_refptr<OSExchangeData> data = new OSExchangeData;
- WriteDragData(press_x, press_y, data.get());
-
- // Message the RootView to do the drag and drop. That way if we're removed
- // the RootView can detect it and avoid calling us back.
- RootView* root_view = GetRootView();
- root_view->StartDragForViewFromMouseEvent(
- this, data, GetDragOperations(press_x, press_y));
-}
-
-AccessibleWrapper* View::GetAccessibleWrapper() {
- if (accessibility_.get() == NULL) {
- accessibility_.reset(new AccessibleWrapper(this));
- }
- return accessibility_.get();
-}
-
-bool View::HitTest(const gfx::Point& l) const {
- if (l.x() >= 0 && l.x() < static_cast<int>(width()) &&
- l.y() >= 0 && l.y() < static_cast<int>(height())) {
- if (HasHitTestMask()) {
- gfx::Path mask;
- GetHitTestMask(&mask);
- ScopedHRGN rgn(mask.CreateHRGN());
- return !!PtInRegion(rgn, l.x(), l.y());
- }
- // No mask, but inside our bounds.
- return true;
- }
- // Outside our bounds.
- return false;
-}
-
-HCURSOR View::GetCursorForPoint(Event::EventType event_type, int x, int y) {
- return NULL;
-}
-
-void View::Focus() {
- // Set the native focus to the root view window so it receives the keyboard
- // messages.
- FocusManager* focus_manager = GetFocusManager();
- if (focus_manager)
- focus_manager->FocusHWND(GetRootView()->GetWidget()->GetHWND());
-}
-
-int View::GetHorizontalDragThreshold() {
- static int threshold = -1;
- if (threshold == -1)
- threshold = GetSystemMetrics(SM_CXDRAG) / 2;
- return threshold;
-}
-
-int View::GetVerticalDragThreshold() {
- static int threshold = -1;
- if (threshold == -1)
- threshold = GetSystemMetrics(SM_CYDRAG) / 2;
- return threshold;
-}
-
-} // namespace views
diff --git a/chrome/views/views.vcproj b/chrome/views/views.vcproj
index 6d5ce3d..172e6f1 100644
--- a/chrome/views/views.vcproj
+++ b/chrome/views/views.vcproj
@@ -490,10 +490,6 @@
>
</File>
<File
- RelativePath=".\root_view_win.cc"
- >
- </File>
- <File
RelativePath=".\scroll_bar.cc"
>
</File>
@@ -622,10 +618,6 @@
>
</File>
<File
- RelativePath=".\view_win.cc"
- >
- </File>
- <File
RelativePath=".\widget.h"
>
</File>
diff --git a/chrome/views/widget.h b/chrome/views/widget.h
index d135860..4192912 100644
--- a/chrome/views/widget.h
+++ b/chrome/views/widget.h
@@ -5,10 +5,8 @@
#ifndef CHROME_VIEWS_WIDGET_H_
#define CHROME_VIEWS_WIDGET_H_
-#if defined(OS_WIN)
// TODO(maruel): Remove once HWND is abstracted.
#include <windows.h>
-#endif
namespace gfx {
class Rect;
@@ -50,10 +48,8 @@ class Widget {
// the window should also become the active window.
virtual void MoveToFront(bool should_activate) = 0;
-#if defined(OS_WIN)
// Returns the Window HWND associated with this Widget.
virtual HWND GetHWND() const = 0;
-#endif
// Forces a paint of a specified rectangle immediately.
virtual void PaintNow(const gfx::Rect& update_rect) = 0;