summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 16:09:33 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 16:09:33 +0000
commit45647af87d1e7e5ed607c6fd82a1ac32a708a725 (patch)
tree258381d5b333c5749616d97c1fe3a6bc4db50e1d /ui
parentab91de22a8a7eef73958b0b4463de89bd7fdbd12 (diff)
downloadchromium_src-45647af87d1e7e5ed607c6fd82a1ac32a708a725.zip
chromium_src-45647af87d1e7e5ed607c6fd82a1ac32a708a725.tar.gz
chromium_src-45647af87d1e7e5ed607c6fd82a1ac32a708a725.tar.bz2
views: Move the remaining file from views/ to ui/views/.
BUG=104039 R=ben@chromium.org TBR=stevenjb@chromium.org Review URL: http://codereview.chromium.org/8771006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112469 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/accessible_pane_view.cc205
-rw-r--r--ui/views/accessible_pane_view.h99
-rw-r--r--ui/views/accessible_pane_view_unittest.cc178
-rw-r--r--ui/views/animation/bounds_animator.h2
-rw-r--r--ui/views/background.cc118
-rw-r--r--ui/views/background.h103
-rw-r--r--ui/views/border.cc92
-rw-r--r--ui/views/border.h62
-rw-r--r--ui/views/bubble/bubble_border.h4
-rw-r--r--ui/views/context_menu_controller.h2
-rw-r--r--ui/views/controls/button/menu_button.h2
-rw-r--r--ui/views/controls/button/text_button.h4
-rw-r--r--ui/views/controls/combobox/native_combobox_gtk.cc2
-rw-r--r--ui/views/controls/combobox/native_combobox_views.cc4
-rw-r--r--ui/views/controls/combobox/native_combobox_wrapper.h2
-rw-r--r--ui/views/controls/focusable_border.h2
-rw-r--r--ui/views/controls/label.cc2
-rw-r--r--ui/views/controls/label_unittest.cc2
-rw-r--r--ui/views/controls/menu/menu.h2
-rw-r--r--ui/views/controls/menu/menu_2.h2
-rw-r--r--ui/views/controls/menu/menu_config.h2
-rw-r--r--ui/views/controls/menu/menu_controller.cc4
-rw-r--r--ui/views/controls/menu/menu_listener.h2
-rw-r--r--ui/views/controls/menu/menu_model_adapter.cc2
-rw-r--r--ui/views/controls/menu/menu_scroll_view_container.cc2
-rw-r--r--ui/views/controls/menu/menu_wrapper.h2
-rw-r--r--ui/views/controls/menu/native_menu_gtk.cc2
-rw-r--r--ui/views/controls/menu/native_menu_win.h2
-rw-r--r--ui/views/controls/message_box_view.cc2
-rw-r--r--ui/views/controls/native/native_view_host_gtk.cc2
-rw-r--r--ui/views/controls/native_control.cc4
-rw-r--r--ui/views/controls/progress_bar.cc6
-rw-r--r--ui/views/controls/scrollbar/base_scroll_bar.h2
-rw-r--r--ui/views/controls/scrollbar/base_scroll_bar_button.h2
-rw-r--r--ui/views/controls/scrollbar/bitmap_scroll_bar.cc2
-rw-r--r--ui/views/controls/scrollbar/native_scroll_bar_wrapper.h2
-rw-r--r--ui/views/controls/scrollbar/scroll_bar.h2
-rw-r--r--ui/views/controls/single_split_view.cc2
-rw-r--r--ui/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc2
-rw-r--r--ui/views/controls/table/table_view.h2
-rw-r--r--ui/views/controls/textfield/native_textfield_views.cc6
-rw-r--r--ui/views/controls/textfield/native_textfield_views.h2
-rw-r--r--ui/views/controls/textfield/native_textfield_views_unittest.cc2
-rw-r--r--ui/views/controls/textfield/native_textfield_win.cc2
-rw-r--r--ui/views/controls/textfield/native_textfield_wrapper.h2
-rw-r--r--ui/views/controls/textfield/textfield_views_model.cc2
-rw-r--r--ui/views/controls/textfield/textfield_views_model.h2
-rw-r--r--ui/views/controls/textfield/textfield_views_model_unittest.cc2
-rw-r--r--ui/views/drag_controller.h2
-rw-r--r--ui/views/drag_utils.h2
-rw-r--r--ui/views/events/event.h2
-rw-r--r--ui/views/examples/native_theme_button_example.cc2
-rw-r--r--ui/views/examples/native_theme_button_example.h4
-rw-r--r--ui/views/focus/accelerator_handler.h2
-rw-r--r--ui/views/focus/focus_manager.h2
-rw-r--r--ui/views/focus/focus_manager_factory.h2
-rw-r--r--ui/views/focus/widget_focus_manager.h2
-rw-r--r--ui/views/ime/input_method.h2
-rw-r--r--ui/views/ime/input_method_delegate.h2
-rw-r--r--ui/views/ime/text_input_type_tracker.h2
-rw-r--r--ui/views/layout/layout_manager.h2
-rw-r--r--ui/views/metrics.h2
-rw-r--r--ui/views/mouse_watcher.h2
-rw-r--r--ui/views/native_theme_delegate.h53
-rw-r--r--ui/views/native_theme_painter.cc56
-rw-r--r--ui/views/native_theme_painter.h45
-rw-r--r--ui/views/paint_lock.cc19
-rw-r--r--ui/views/paint_lock.h36
-rw-r--r--ui/views/painter.cc199
-rw-r--r--ui/views/painter.h88
-rw-r--r--ui/views/repeat_controller.cc45
-rw-r--r--ui/views/repeat_controller.h50
-rw-r--r--ui/views/run_all_unittests.cc34
-rw-r--r--ui/views/test/test_views_delegate.h2
-rw-r--r--ui/views/touchui/touch_selection_controller_impl.cc2
-rw-r--r--ui/views/touchui/touch_selection_controller_impl.h2
-rw-r--r--ui/views/view.cc4
-rw-r--r--ui/views/view.h4
-rw-r--r--ui/views/view_constants.cc13
-rw-r--r--ui/views/view_constants.h28
-rw-r--r--ui/views/view_text_utils.cc164
-rw-r--r--ui/views/view_text_utils.h76
-rw-r--r--ui/views/view_unittest.cc4
-rw-r--r--ui/views/views_delegate.h91
-rw-r--r--ui/views/views_export.h29
-rw-r--r--ui/views/widget/default_theme_provider.h2
-rw-r--r--ui/views/widget/monitor_win.h3
-rw-r--r--ui/views/widget/native_widget_aura.h2
-rw-r--r--ui/views/widget/native_widget_delegate.h2
-rw-r--r--ui/views/widget/native_widget_gtk.cc2
-rw-r--r--ui/views/widget/native_widget_win.cc2
-rw-r--r--ui/views/widget/tooltip_manager.h2
-rw-r--r--ui/views/widget/tooltip_manager_views.cc4
-rw-r--r--ui/views/widget/widget.cc2
-rw-r--r--ui/views/widget/widget_delegate.cc2
-rw-r--r--ui/views/widget/widget_unittest.cc2
-rw-r--r--ui/views/widget/window_manager.h2
-rw-r--r--ui/views/window/window_shape.h2
98 files changed, 1973 insertions, 89 deletions
diff --git a/ui/views/accessible_pane_view.cc b/ui/views/accessible_pane_view.cc
new file mode 100644
index 0000000..dfb0ca8
--- /dev/null
+++ b/ui/views/accessible_pane_view.cc
@@ -0,0 +1,205 @@
+// 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 "ui/views/accessible_pane_view.h"
+
+#include "base/message_loop.h"
+#include "ui/base/accessibility/accessible_view_state.h"
+#include "ui/views/focus/focus_search.h"
+#include "ui/views/focus/view_storage.h"
+#include "ui/views/widget/widget.h"
+
+namespace views {
+
+AccessiblePaneView::AccessiblePaneView()
+ : pane_has_focus_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
+ focus_manager_(NULL),
+ home_key_(ui::VKEY_HOME, false, false, false),
+ end_key_(ui::VKEY_END, false, false, false),
+ escape_key_(ui::VKEY_ESCAPE, false, false, false),
+ left_key_(ui::VKEY_LEFT, false, false, false),
+ right_key_(ui::VKEY_RIGHT, false, false, false) {
+ focus_search_.reset(new views::FocusSearch(this, true, true));
+}
+
+AccessiblePaneView::~AccessiblePaneView() {
+ if (pane_has_focus_) {
+ focus_manager_->RemoveFocusChangeListener(this);
+ }
+}
+
+bool AccessiblePaneView::SetPaneFocus(views::View* initial_focus) {
+ if (!IsVisible())
+ return false;
+
+ if (!focus_manager_)
+ focus_manager_ = GetFocusManager();
+
+ focus_manager_->StoreFocusedView();
+
+ // Use the provided initial focus if it's visible and enabled, otherwise
+ // use the first focusable child.
+ if (!initial_focus ||
+ !Contains(initial_focus) ||
+ !initial_focus->IsVisible() ||
+ !initial_focus->IsEnabled()) {
+ initial_focus = GetFirstFocusableChild();
+ }
+
+ // Return false if there are no focusable children.
+ if (!initial_focus)
+ return false;
+
+ focus_manager_->SetFocusedView(initial_focus);
+
+ // If we already have pane focus, we're done.
+ if (pane_has_focus_)
+ return true;
+
+ // Otherwise, set accelerators and start listening for focus change events.
+ pane_has_focus_ = true;
+ focus_manager_->RegisterAccelerator(home_key_, this);
+ focus_manager_->RegisterAccelerator(end_key_, this);
+ focus_manager_->RegisterAccelerator(escape_key_, this);
+ focus_manager_->RegisterAccelerator(left_key_, this);
+ focus_manager_->RegisterAccelerator(right_key_, this);
+ focus_manager_->AddFocusChangeListener(this);
+
+ return true;
+}
+
+bool AccessiblePaneView::SetPaneFocusAndFocusDefault() {
+ return SetPaneFocus(GetDefaultFocusableChild());
+}
+
+views::View* AccessiblePaneView::GetDefaultFocusableChild() {
+ return NULL;
+}
+
+void AccessiblePaneView::RemovePaneFocus() {
+ focus_manager_->RemoveFocusChangeListener(this);
+ pane_has_focus_ = false;
+
+ focus_manager_->UnregisterAccelerator(home_key_, this);
+ focus_manager_->UnregisterAccelerator(end_key_, this);
+ focus_manager_->UnregisterAccelerator(escape_key_, this);
+ focus_manager_->UnregisterAccelerator(left_key_, this);
+ focus_manager_->UnregisterAccelerator(right_key_, this);
+}
+
+views::View* AccessiblePaneView::GetFirstFocusableChild() {
+ FocusTraversable* dummy_focus_traversable;
+ views::View* dummy_focus_traversable_view;
+ return focus_search_->FindNextFocusableView(
+ NULL, false, views::FocusSearch::DOWN, false,
+ &dummy_focus_traversable, &dummy_focus_traversable_view);
+}
+
+views::View* AccessiblePaneView::GetLastFocusableChild() {
+ FocusTraversable* dummy_focus_traversable;
+ views::View* dummy_focus_traversable_view;
+ return focus_search_->FindNextFocusableView(
+ this, true, views::FocusSearch::DOWN, false,
+ &dummy_focus_traversable, &dummy_focus_traversable_view);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// View overrides:
+
+views::FocusTraversable* AccessiblePaneView::GetPaneFocusTraversable() {
+ if (pane_has_focus_)
+ return this;
+ else
+ return NULL;
+}
+
+bool AccessiblePaneView::AcceleratorPressed(
+ const ui::Accelerator& accelerator) {
+
+ const views::View* focused_view = focus_manager_->GetFocusedView();
+ if (!Contains(focused_view))
+ return false;
+
+ switch (accelerator.key_code()) {
+ case ui::VKEY_ESCAPE:
+ RemovePaneFocus();
+ focus_manager_->RestoreFocusedView();
+ return true;
+ case ui::VKEY_LEFT:
+ focus_manager_->AdvanceFocus(true);
+ return true;
+ case ui::VKEY_RIGHT:
+ focus_manager_->AdvanceFocus(false);
+ return true;
+ case ui::VKEY_HOME:
+ focus_manager_->SetFocusedViewWithReason(
+ GetFirstFocusableChild(), views::FocusManager::kReasonFocusTraversal);
+ return true;
+ case ui::VKEY_END:
+ focus_manager_->SetFocusedViewWithReason(
+ GetLastFocusableChild(), views::FocusManager::kReasonFocusTraversal);
+ return true;
+ default:
+ return false;
+ }
+}
+
+void AccessiblePaneView::SetVisible(bool flag) {
+ if (IsVisible() && !flag && pane_has_focus_) {
+ RemovePaneFocus();
+ focus_manager_->RestoreFocusedView();
+ }
+ View::SetVisible(flag);
+}
+
+void AccessiblePaneView::GetAccessibleState(ui::AccessibleViewState* state) {
+ state->role = ui::AccessibilityTypes::ROLE_PANE;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// FocusChangeListener overrides:
+
+void AccessiblePaneView::OnWillChangeFocus(views::View* focused_before,
+ views::View* focused_now) {
+ // Act when focus has changed.
+}
+
+void AccessiblePaneView::OnDidChangeFocus(views::View* focused_before,
+ views::View* focused_now) {
+ if (!focused_now)
+ return;
+
+ views::FocusManager::FocusChangeReason reason =
+ focus_manager_->focus_change_reason();
+
+ if (!Contains(focused_now) ||
+ reason == views::FocusManager::kReasonDirectFocusChange) {
+ // We should remove pane focus (i.e. make most of the controls
+ // not focusable again) because the focus has left the pane,
+ // or because the focus changed within the pane due to the user
+ // directly focusing to a specific view (e.g., clicking on it).
+ RemovePaneFocus();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// FocusTraversable overrides:
+
+views::FocusSearch* AccessiblePaneView::GetFocusSearch() {
+ DCHECK(pane_has_focus_);
+ return focus_search_.get();
+}
+
+views::FocusTraversable* AccessiblePaneView::GetFocusTraversableParent() {
+ DCHECK(pane_has_focus_);
+ return NULL;
+}
+
+views::View* AccessiblePaneView::GetFocusTraversableParentView() {
+ DCHECK(pane_has_focus_);
+ return NULL;
+}
+
+} // namespace views
diff --git a/ui/views/accessible_pane_view.h b/ui/views/accessible_pane_view.h
new file mode 100644
index 0000000..4a150d0
--- /dev/null
+++ b/ui/views/accessible_pane_view.h
@@ -0,0 +1,99 @@
+// 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 UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_
+#define UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_
+#pragma once
+
+#include "base/hash_tables.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "ui/base/accelerators/accelerator.h"
+#include "ui/views/focus/focus_manager.h"
+#include "ui/views/view.h"
+
+namespace views {
+class FocusSearch;
+
+// This class provides keyboard access to any view that extends it, typically
+// a toolbar. The user sets focus to a control in this view by pressing
+// F6 to traverse all panes, or by pressing a shortcut that jumps directly
+// to this pane.
+class VIEWS_EXPORT AccessiblePaneView : public View,
+ public FocusChangeListener,
+ public FocusTraversable {
+ public:
+ AccessiblePaneView();
+ virtual ~AccessiblePaneView();
+
+ // Set focus to the pane with complete keyboard access.
+ // Focus will be restored to the last focused view if the user escapes.
+ // If |initial_focus| is not NULL, that control will get
+ // the initial focus, if it's enabled and focusable. Returns true if
+ // the pane was able to receive focus.
+ virtual bool SetPaneFocus(View* initial_focus);
+
+ // Set focus to the pane with complete keyboard access, with the
+ // focus initially set to the default child. Focus will be restored
+ // to the last focused view if the user escapes.
+ // Returns true if the pane was able to receive focus.
+ virtual bool SetPaneFocusAndFocusDefault();
+
+ // Overridden from View:
+ virtual FocusTraversable* GetPaneFocusTraversable() OVERRIDE;
+ virtual bool AcceleratorPressed(const ui::Accelerator& accelerator)
+ OVERRIDE;
+ virtual void SetVisible(bool flag) OVERRIDE;
+ virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
+
+ // Overridden from FocusChangeListener:
+ virtual void OnWillChangeFocus(View* focused_before,
+ View* focused_now) OVERRIDE;
+ virtual void OnDidChangeFocus(View* focused_before,
+ View* focused_now) OVERRIDE;
+
+ // Overridden from FocusTraversable:
+ virtual FocusSearch* GetFocusSearch() OVERRIDE;
+ virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE;
+ virtual View* GetFocusTraversableParentView() OVERRIDE;
+
+ protected:
+ // A subclass can override this to provide a default focusable child
+ // other than the first focusable child.
+ virtual View* GetDefaultFocusableChild();
+
+ // Remove pane focus.
+ virtual void RemovePaneFocus();
+
+ void RestoreLastFocusedView();
+
+ View* GetFirstFocusableChild();
+ View* GetLastFocusableChild();
+
+ bool pane_has_focus_;
+
+ base::WeakPtrFactory<AccessiblePaneView> method_factory_;
+
+ // Save the focus manager rather than calling GetFocusManager(),
+ // so that we can remove focus listeners in the destructor.
+ FocusManager* focus_manager_;
+
+ // Our custom focus search implementation that traps focus in this
+ // pane and traverses all views that are focusable for accessibility,
+ // not just those that are normally focusable.
+ scoped_ptr<FocusSearch> focus_search_;
+
+ // Registered accelerators
+ ui::Accelerator home_key_;
+ ui::Accelerator end_key_;
+ ui::Accelerator escape_key_;
+ ui::Accelerator left_key_;
+ ui::Accelerator right_key_;
+
+ DISALLOW_COPY_AND_ASSIGN(AccessiblePaneView);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_
diff --git a/ui/views/accessible_pane_view_unittest.cc b/ui/views/accessible_pane_view_unittest.cc
new file mode 100644
index 0000000..467f143
--- /dev/null
+++ b/ui/views/accessible_pane_view_unittest.cc
@@ -0,0 +1,178 @@
+// 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 "ui/views/accessible_pane_view.h"
+
+#include "ui/base/accelerators/accelerator.h"
+#include "ui/views/controls/button/text_button.h"
+#include "ui/views/layout/fill_layout.h"
+#include "ui/views/test/views_test_base.h"
+#include "ui/views/widget/widget.h"
+
+namespace views {
+
+// TODO(alicet): bring pane rotation into views and add tests.
+// See browser_view.cc for details.
+
+typedef ViewsTestBase AccessiblePaneViewTest;
+
+class TestBarView : public AccessiblePaneView,
+ public ButtonListener {
+ public:
+ TestBarView();
+ virtual ~TestBarView();
+
+ virtual void ButtonPressed(Button* sender,
+ const views::Event& event) OVERRIDE;
+ TextButton* child_button() const { return child_button_.get(); }
+ TextButton* second_child_button() const { return second_child_button_.get(); }
+ TextButton* third_child_button() const { return third_child_button_.get(); }
+ TextButton* not_child_button() const { return not_child_button_.get(); }
+
+ const ui::Accelerator& home_key() const { return home_key_; }
+ const ui::Accelerator& end_key() const { return end_key_; }
+ const ui::Accelerator& escape_key() const { return escape_key_; }
+ const ui::Accelerator& left_key() const { return left_key_; }
+ const ui::Accelerator& right_key() const { return right_key_; }
+
+ virtual View* GetDefaultFocusableChild() OVERRIDE;
+
+ private:
+ void Init();
+
+ scoped_ptr<TextButton> child_button_;
+ scoped_ptr<TextButton> second_child_button_;
+ scoped_ptr<TextButton> third_child_button_;
+ scoped_ptr<TextButton> not_child_button_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestBarView);
+};
+
+TestBarView::TestBarView() {
+ Init();
+}
+
+TestBarView::~TestBarView() {}
+
+void TestBarView::ButtonPressed(views::Button* sender,
+ const views::Event& event) {}
+
+void TestBarView::Init() {
+ SetLayoutManager(new views::FillLayout());
+ string16 label;
+ child_button_.reset(new TextButton(this, label));
+ AddChildView(child_button_.get());
+ second_child_button_.reset(new TextButton(this, label));
+ AddChildView(second_child_button_.get());
+ third_child_button_.reset(new TextButton(this, label));
+ AddChildView(third_child_button_.get());
+ not_child_button_.reset(new TextButton(this, label));
+}
+
+View* TestBarView::GetDefaultFocusableChild() {
+ return child_button_.get();
+}
+
+TEST_F(AccessiblePaneViewTest, SimpleSetPaneFocus) {
+ TestBarView* test_view = new TestBarView();
+ scoped_ptr<Widget> widget(new Widget());
+ Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.bounds = gfx::Rect(50, 50, 650, 650);
+ widget->Init(params);
+ View* root = widget->GetRootView();
+ root->AddChildView(test_view);
+ widget->Show();
+
+ // Set pane focus succeeds, focus on child.
+ EXPECT_TRUE(test_view->SetPaneFocusAndFocusDefault());
+ EXPECT_EQ(test_view, test_view->GetPaneFocusTraversable());
+ EXPECT_EQ(test_view->child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+
+ // Set focus on non child view, focus failed, stays on pane.
+ EXPECT_TRUE(test_view->SetPaneFocus(test_view->not_child_button()));
+ EXPECT_FALSE(test_view->not_child_button() ==
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+ EXPECT_EQ(test_view->child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+ widget->CloseNow();
+ widget.reset();
+}
+
+TEST_F(AccessiblePaneViewTest, TwoSetPaneFocus) {
+ TestBarView* test_view = new TestBarView();
+ TestBarView* test_view_2 = new TestBarView();
+ scoped_ptr<Widget> widget(new Widget());
+ Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.bounds = gfx::Rect(50, 50, 650, 650);
+ widget->Init(params);
+ View* root = widget->GetRootView();
+ root->AddChildView(test_view);
+ root->AddChildView(test_view_2);
+ widget->Show();
+
+ // Set pane focus succeeds, focus on child.
+ EXPECT_TRUE(test_view->SetPaneFocusAndFocusDefault());
+ EXPECT_EQ(test_view, test_view->GetPaneFocusTraversable());
+ EXPECT_EQ(test_view->child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+
+ // Set focus on another test_view, focus move to that pane.
+ EXPECT_TRUE(test_view_2->SetPaneFocus(test_view_2->second_child_button()));
+ EXPECT_FALSE(test_view->child_button() ==
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+ EXPECT_EQ(test_view_2->second_child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+ widget->CloseNow();
+ widget.reset();
+}
+
+TEST_F(AccessiblePaneViewTest, PaneFocusTraversal) {
+ TestBarView* test_view = new TestBarView();
+ TestBarView* original_test_view = new TestBarView();
+ scoped_ptr<Widget> widget(new Widget());
+ Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.bounds = gfx::Rect(50, 50, 650, 650);
+ widget->Init(params);
+ View* root = widget->GetRootView();
+ root->AddChildView(original_test_view);
+ root->AddChildView(test_view);
+ widget->Show();
+
+ // Set pane focus on first view.
+ EXPECT_TRUE(original_test_view->SetPaneFocus(
+ original_test_view->third_child_button()));
+
+ // Test travesal in second view.
+ // Set pane focus on second child.
+ EXPECT_TRUE(test_view->SetPaneFocus(test_view->second_child_button()));
+ // home
+ test_view->AcceleratorPressed(test_view->home_key());
+ EXPECT_EQ(test_view->child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+ // end
+ test_view->AcceleratorPressed(test_view->end_key());
+ EXPECT_EQ(test_view->third_child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+ // left
+ test_view->AcceleratorPressed(test_view->left_key());
+ EXPECT_EQ(test_view->second_child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+ // right, right
+ test_view->AcceleratorPressed(test_view->right_key());
+ test_view->AcceleratorPressed(test_view->right_key());
+ EXPECT_EQ(test_view->child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+
+ // ESC
+ test_view->AcceleratorPressed(test_view->escape_key());
+ EXPECT_EQ(original_test_view->third_child_button(),
+ test_view->GetWidget()->GetFocusManager()->GetFocusedView());
+ widget->CloseNow();
+ widget.reset();
+}
+} // namespace views
diff --git a/ui/views/animation/bounds_animator.h b/ui/views/animation/bounds_animator.h
index 37f4ec4..d0e2c2e 100644
--- a/ui/views/animation/bounds_animator.h
+++ b/ui/views/animation/bounds_animator.h
@@ -13,7 +13,7 @@
#include "ui/base/animation/animation_container_observer.h"
#include "ui/base/animation/animation_delegate.h"
#include "ui/gfx/rect.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace ui {
class SlideAnimation;
diff --git a/ui/views/background.cc b/ui/views/background.cc
new file mode 100644
index 0000000..c606842
--- /dev/null
+++ b/ui/views/background.cc
@@ -0,0 +1,118 @@
+// 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 "ui/views/background.h"
+
+#include "base/logging.h"
+#include "skia/ext/skia_utils_win.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/gfx/canvas_skia.h"
+#include "ui/gfx/color_utils.h"
+#include "ui/views/painter.h"
+#include "ui/views/view.h"
+
+namespace views {
+
+// SolidBackground is a trivial Background implementation that fills the
+// background in a solid color.
+class SolidBackground : public Background {
+ public:
+ explicit SolidBackground(const SkColor& color) {
+ SetNativeControlColor(color);
+ }
+
+ void Paint(gfx::Canvas* canvas, View* view) const {
+ // Fill the background. Note that we don't constrain to the bounds as
+ // canvas is already clipped for us.
+ canvas->GetSkCanvas()->drawColor(get_color());
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SolidBackground);
+};
+
+class BackgroundPainter : public Background {
+ public:
+ BackgroundPainter(bool owns_painter, Painter* painter)
+ : owns_painter_(owns_painter), painter_(painter) {
+ DCHECK(painter);
+ }
+
+ virtual ~BackgroundPainter() {
+ if (owns_painter_)
+ delete painter_;
+ }
+
+
+ void Paint(gfx::Canvas* canvas, View* view) const {
+ Painter::PaintPainterAt(0, 0, view->width(), view->height(), canvas,
+ painter_);
+ }
+
+ private:
+ bool owns_painter_;
+ Painter* painter_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundPainter);
+};
+
+Background::Background()
+ : color_(SK_ColorWHITE)
+#if defined(OS_WIN)
+ , native_control_brush_(NULL)
+#endif
+{
+}
+
+Background::~Background() {
+#if defined(OS_WIN)
+ DeleteObject(native_control_brush_);
+#endif
+}
+
+void Background::SetNativeControlColor(SkColor color) {
+ color_ = color;
+#if defined(OS_WIN)
+ DeleteObject(native_control_brush_);
+ native_control_brush_ = NULL;
+#endif
+}
+
+#if defined(OS_WIN)
+HBRUSH Background::GetNativeControlBrush() const {
+ if (!native_control_brush_)
+ native_control_brush_ = CreateSolidBrush(skia::SkColorToCOLORREF(color_));
+ return native_control_brush_;
+}
+#endif
+
+//static
+Background* Background::CreateSolidBackground(const SkColor& color) {
+ return new SolidBackground(color);
+}
+
+//static
+Background* Background::CreateStandardPanelBackground() {
+ return CreateVerticalGradientBackground(SkColorSetRGB(246, 250, 255),
+ SkColorSetRGB(219, 235, 255));
+}
+
+//static
+Background* Background::CreateVerticalGradientBackground(
+ const SkColor& color1, const SkColor& color2) {
+ Background* background = CreateBackgroundPainter(
+ true, Painter::CreateVerticalGradient(color1, color2));
+ background->SetNativeControlColor(
+ color_utils::AlphaBlend(color1, color2, 128));
+
+ return background;
+}
+
+//static
+Background* Background::CreateBackgroundPainter(bool owns_painter,
+ Painter* painter) {
+ return new BackgroundPainter(owns_painter, painter);
+}
+
+} // namespace views
diff --git a/ui/views/background.h b/ui/views/background.h
new file mode 100644
index 0000000..64f609c
--- /dev/null
+++ b/ui/views/background.h
@@ -0,0 +1,103 @@
+// 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 UI_VIEWS_BACKGROUND_H_
+#define UI_VIEWS_BACKGROUND_H_
+#pragma once
+
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif // defined(OS_WIN)
+
+#include "base/basictypes.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/views/views_export.h"
+
+namespace gfx {
+class Canvas;
+}
+
+namespace views {
+
+class Painter;
+class View;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Background class
+//
+// A background implements a way for views to paint a background. The
+// background can be either solid or based on a gradient. Of course,
+// Background can be subclassed to implement various effects.
+//
+// Any View can have a background. See View::SetBackground() and
+// View::OnPaintBackground()
+//
+/////////////////////////////////////////////////////////////////////////////
+class VIEWS_EXPORT Background {
+ public:
+ Background();
+ virtual ~Background();
+
+ // Creates a background that fills the canvas in the specified color.
+ static Background* CreateSolidBackground(const SkColor& color);
+
+ // Creates a background that fills the canvas in the specified color.
+ static Background* CreateSolidBackground(int r, int g, int b) {
+ return CreateSolidBackground(SkColorSetRGB(r, g, b));
+ }
+
+ // Creates a background that fills the canvas in the specified color.
+ static Background* CreateSolidBackground(int r, int g, int b, int a) {
+ return CreateSolidBackground(SkColorSetARGB(a, r, g, b));
+ }
+
+ // Creates a background that contains a vertical gradient that varies
+ // from |color1| to |color2|
+ static Background* CreateVerticalGradientBackground(const SkColor& color1,
+ const SkColor& color2);
+
+ // Creates Chrome's standard panel background
+ static Background* CreateStandardPanelBackground();
+
+ // Creates a Background from the specified Painter. If owns_painter is
+ // true, the Painter is deleted when the Border is deleted.
+ static Background* CreateBackgroundPainter(bool owns_painter,
+ Painter* painter);
+
+ // Render the background for the provided view
+ virtual void Paint(gfx::Canvas* canvas, View* view) const = 0;
+
+ // Set a solid, opaque color to be used when drawing backgrounds of native
+ // controls. Unfortunately alpha=0 is not an option.
+ void SetNativeControlColor(SkColor color);
+
+ // Returns the "background color". This is equivalent to the color set in
+ // SetNativeControlColor(). For solid backgrounds, this is the color; for
+ // gradient backgrounds, it's the midpoint of the gradient; for painter
+ // backgrounds, this is not useful (returns a default color).
+ SkColor get_color() const { return color_; }
+
+#if defined(OS_WIN)
+ // TODO(port): Make GetNativeControlBrush portable (currently uses HBRUSH).
+
+ // Get the brush that was specified by SetNativeControlColor
+ HBRUSH GetNativeControlBrush() const;
+#endif // defined(OS_WIN)
+
+ private:
+ SkColor color_;
+#if defined(OS_WIN)
+ // TODO(port): Create portable replacement for HBRUSH.
+ mutable HBRUSH native_control_brush_;
+#endif // defined(OS_WIN)
+
+ DISALLOW_COPY_AND_ASSIGN(Background);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_BACKGROUND_H_
diff --git a/ui/views/border.cc b/ui/views/border.cc
new file mode 100644
index 0000000..08127bd
--- /dev/null
+++ b/ui/views/border.cc
@@ -0,0 +1,92 @@
+// 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 "ui/views/border.h"
+
+#include "base/logging.h"
+#include "ui/gfx/canvas.h"
+
+namespace views {
+
+namespace {
+
+// A simple border with a fixed thickness and single color.
+class SolidBorder : public Border {
+ public:
+ SolidBorder(int thickness, SkColor color);
+
+ virtual void Paint(const View& view, gfx::Canvas* canvas) const;
+ virtual void GetInsets(gfx::Insets* insets) const;
+
+ private:
+ int thickness_;
+ SkColor color_;
+ gfx::Insets insets_;
+
+ DISALLOW_COPY_AND_ASSIGN(SolidBorder);
+};
+
+SolidBorder::SolidBorder(int thickness, SkColor color)
+ : thickness_(thickness),
+ color_(color),
+ insets_(thickness, thickness, thickness, thickness) {
+}
+
+void SolidBorder::Paint(const View& view, gfx::Canvas* canvas) const {
+ // Top border.
+ canvas->FillRect(color_, gfx::Rect(0, 0, view.width(), insets_.top()));
+ // Left border.
+ canvas->FillRect(color_, gfx::Rect(0, 0, insets_.left(), view.height()));
+ // Bottom border.
+ canvas->FillRect(color_, gfx::Rect(0, view.height() - insets_.bottom(),
+ view.width(), insets_.bottom()));
+ // Right border.
+ canvas->FillRect(color_, gfx::Rect(view.width() - insets_.right(), 0,
+ insets_.right(), view.height()));
+}
+
+void SolidBorder::GetInsets(gfx::Insets* insets) const {
+ DCHECK(insets);
+ insets->Set(insets_.top(), insets_.left(), insets_.bottom(), insets_.right());
+}
+
+class EmptyBorder : public Border {
+ public:
+ EmptyBorder(int top, int left, int bottom, int right)
+ : top_(top), left_(left), bottom_(bottom), right_(right) {}
+
+ virtual void Paint(const View& view, gfx::Canvas* canvas) const {}
+
+ virtual void GetInsets(gfx::Insets* insets) const {
+ DCHECK(insets);
+ insets->Set(top_, left_, bottom_, right_);
+ }
+
+ private:
+ int top_;
+ int left_;
+ int bottom_;
+ int right_;
+
+ DISALLOW_COPY_AND_ASSIGN(EmptyBorder);
+};
+}
+
+Border::Border() {
+}
+
+Border::~Border() {
+}
+
+// static
+Border* Border::CreateSolidBorder(int thickness, SkColor color) {
+ return new SolidBorder(thickness, color);
+}
+
+// static
+Border* Border::CreateEmptyBorder(int top, int left, int bottom, int right) {
+ return new EmptyBorder(top, left, bottom, right);
+}
+
+} // namespace views
diff --git a/ui/views/border.h b/ui/views/border.h
new file mode 100644
index 0000000..6b4808f
--- /dev/null
+++ b/ui/views/border.h
@@ -0,0 +1,62 @@
+// 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 UI_VIEWS_BORDER_H_
+#define UI_VIEWS_BORDER_H_
+#pragma once
+
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/gfx/insets.h"
+#include "ui/views/view.h"
+
+namespace gfx{
+class Canvas;
+}
+
+namespace views {
+
+class View;
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Border class.
+//
+// The border class is used to display a border around a view.
+// To set a border on a view, just call SetBorder on the view, for example:
+// view->set_border(Border::CreateSolidBorder(1, SkColorSetRGB(25, 25, 112));
+// Once set on a view, the border is owned by the view.
+//
+// IMPORTANT NOTE: not all views support borders at this point. In order to
+// support the border, views should make sure to use bounds excluding the
+// border (by calling View::GetLocalBoundsExcludingBorder) when doing layout and
+// painting.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+class VIEWS_EXPORT Border {
+ public:
+ Border();
+ virtual ~Border();
+
+ // Creates a border that is a simple line of the specified thickness and
+ // color.
+ static Border* CreateSolidBorder(int thickness, SkColor color);
+
+ // Creates a border for reserving space. The returned border does not
+ // paint anything.
+ static Border* CreateEmptyBorder(int top, int left, int bottom, int right);
+
+ // Renders the border for the specified view.
+ virtual void Paint(const View& view, gfx::Canvas* canvas) const = 0;
+
+ // Sets the specified insets to the the border insets.
+ virtual void GetInsets(gfx::Insets* insets) const = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Border);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_BORDER_H_
diff --git a/ui/views/bubble/bubble_border.h b/ui/views/bubble/bubble_border.h
index 9dc535f..a79cd9e 100644
--- a/ui/views/bubble/bubble_border.h
+++ b/ui/views/bubble/bubble_border.h
@@ -7,8 +7,8 @@
#pragma once
#include "base/compiler_specific.h"
-#include "views/background.h"
-#include "views/border.h"
+#include "ui/views/background.h"
+#include "ui/views/border.h"
class SkBitmap;
diff --git a/ui/views/context_menu_controller.h b/ui/views/context_menu_controller.h
index 577ec62..5bee8b7 100644
--- a/ui/views/context_menu_controller.h
+++ b/ui/views/context_menu_controller.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_CONTEXT_MENU_CONTROLLER_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Point;
diff --git a/ui/views/controls/button/menu_button.h b/ui/views/controls/button/menu_button.h
index 7512dfe..7f39e77 100644
--- a/ui/views/controls/button/menu_button.h
+++ b/ui/views/controls/button/menu_button.h
@@ -11,8 +11,8 @@
#include "base/string16.h"
#include "base/time.h"
#include "ui/gfx/font.h"
+#include "ui/views/background.h"
#include "ui/views/controls/button/text_button.h"
-#include "views/background.h"
namespace views {
diff --git a/ui/views/controls/button/text_button.h b/ui/views/controls/button/text_button.h
index fcf9299..c47727d 100644
--- a/ui/views/controls/button/text_button.h
+++ b/ui/views/controls/button/text_button.h
@@ -13,9 +13,9 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/font.h"
+#include "ui/views/border.h"
#include "ui/views/controls/button/custom_button.h"
-#include "views/border.h"
-#include "views/native_theme_delegate.h"
+#include "ui/views/native_theme_delegate.h"
namespace views {
diff --git a/ui/views/controls/combobox/native_combobox_gtk.cc b/ui/views/controls/combobox/native_combobox_gtk.cc
index a09ad57..6ef1fbf 100644
--- a/ui/views/controls/combobox/native_combobox_gtk.cc
+++ b/ui/views/controls/combobox/native_combobox_gtk.cc
@@ -13,8 +13,8 @@
#include "ui/base/models/combobox_model.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/combobox/native_combobox_views.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
-#include "views/views_delegate.h"
namespace views {
diff --git a/ui/views/controls/combobox/native_combobox_views.cc b/ui/views/controls/combobox/native_combobox_views.cc
index 4311b8f..cb5e1ce 100644
--- a/ui/views/controls/combobox/native_combobox_views.cc
+++ b/ui/views/controls/combobox/native_combobox_views.cc
@@ -15,14 +15,14 @@
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/font.h"
#include "ui/gfx/path.h"
+#include "ui/views/background.h"
+#include "ui/views/border.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/focusable_border.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget.h"
-#include "views/background.h"
-#include "views/border.h"
#if defined(OS_LINUX)
#include "ui/gfx/gtk_util.h"
diff --git a/ui/views/controls/combobox/native_combobox_wrapper.h b/ui/views/controls/combobox/native_combobox_wrapper.h
index 959871e..f11a2f6 100644
--- a/ui/views/controls/combobox/native_combobox_wrapper.h
+++ b/ui/views/controls/combobox/native_combobox_wrapper.h
@@ -7,7 +7,7 @@
#pragma once
#include "ui/gfx/native_widget_types.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx{
class Size;
diff --git a/ui/views/controls/focusable_border.h b/ui/views/controls/focusable_border.h
index 903bb61..4b64bc6 100644
--- a/ui/views/controls/focusable_border.h
+++ b/ui/views/controls/focusable_border.h
@@ -8,8 +8,8 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "ui/views/border.h"
#include "ui/views/view.h"
-#include "views/border.h"
namespace gfx {
class Canvas;
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index 452322e..aadac0e2 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -21,7 +21,7 @@
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h"
#include "ui/gfx/insets.h"
-#include "views/background.h"
+#include "ui/views/background.h"
namespace views {
diff --git a/ui/views/controls/label_unittest.cc b/ui/views/controls/label_unittest.cc
index 426614b..b2e2bc4 100644
--- a/ui/views/controls/label_unittest.cc
+++ b/ui/views/controls/label_unittest.cc
@@ -8,8 +8,8 @@
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/canvas.h"
+#include "ui/views/border.h"
#include "ui/views/controls/label.h"
-#include "views/border.h"
namespace views {
diff --git a/ui/views/controls/menu/menu.h b/ui/views/controls/menu/menu.h
index ed20389..2ee90f9 100644
--- a/ui/views/controls/menu/menu.h
+++ b/ui/views/controls/menu/menu.h
@@ -11,7 +11,7 @@
#include "base/basictypes.h"
#include "base/string16.h"
#include "ui/gfx/native_widget_types.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
class SkBitmap;
diff --git a/ui/views/controls/menu/menu_2.h b/ui/views/controls/menu/menu_2.h
index 898596e3..0b6fcae 100644
--- a/ui/views/controls/menu/menu_2.h
+++ b/ui/views/controls/menu/menu_2.h
@@ -10,7 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/menu/menu_wrapper.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Point;
diff --git a/ui/views/controls/menu/menu_config.h b/ui/views/controls/menu/menu_config.h
index 92014f9..ac568b0 100644
--- a/ui/views/controls/menu/menu_config.h
+++ b/ui/views/controls/menu/menu_config.h
@@ -8,7 +8,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/font.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index bb96e93..c81f32f 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -19,10 +19,10 @@
#include "ui/views/controls/menu/menu_scroll_view_container.h"
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/drag_utils.h"
+#include "ui/views/view_constants.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget.h"
-#include "views/view_constants.h"
-#include "views/views_delegate.h"
#if defined(USE_AURA)
#include "ui/aura/desktop.h"
diff --git a/ui/views/controls/menu/menu_listener.h b/ui/views/controls/menu/menu_listener.h
index 37eb8c0..120263b 100644
--- a/ui/views/controls/menu/menu_listener.h
+++ b/ui/views/controls/menu/menu_listener.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_CONTROLS_MENU_MENU_LISTENER_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/controls/menu/menu_model_adapter.cc b/ui/views/controls/menu/menu_model_adapter.cc
index 3848093..759fda3 100644
--- a/ui/views/controls/menu/menu_model_adapter.cc
+++ b/ui/views/controls/menu/menu_model_adapter.cc
@@ -8,7 +8,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/menu_model.h"
#include "ui/views/controls/menu/submenu_view.h"
-#include "views/views_delegate.h"
+#include "ui/views/views_delegate.h"
namespace views {
diff --git a/ui/views/controls/menu/menu_scroll_view_container.cc b/ui/views/controls/menu/menu_scroll_view_container.cc
index 775218f..131df17 100644
--- a/ui/views/controls/menu/menu_scroll_view_container.cc
+++ b/ui/views/controls/menu/menu_scroll_view_container.cc
@@ -14,11 +14,11 @@
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/native_theme.h"
+#include "ui/views/border.h"
#include "ui/views/controls/menu/menu_config.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/submenu_view.h"
-#include "views/border.h"
using gfx::NativeTheme;
diff --git a/ui/views/controls/menu/menu_wrapper.h b/ui/views/controls/menu/menu_wrapper.h
index 2d21953..4975ebf 100644
--- a/ui/views/controls/menu/menu_wrapper.h
+++ b/ui/views/controls/menu/menu_wrapper.h
@@ -7,7 +7,7 @@
#pragma once
#include "ui/gfx/native_widget_types.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Point;
diff --git a/ui/views/controls/menu/native_menu_gtk.cc b/ui/views/controls/menu/native_menu_gtk.cc
index 97ca02a..87b2fac 100644
--- a/ui/views/controls/menu/native_menu_gtk.cc
+++ b/ui/views/controls/menu/native_menu_gtk.cc
@@ -23,8 +23,8 @@
#include "ui/views/controls/menu/menu_2.h"
#include "ui/views/controls/menu/menu_listener.h"
#include "ui/views/controls/menu/nested_dispatcher_gtk.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget_gtk.h"
-#include "views/views_delegate.h"
namespace {
diff --git a/ui/views/controls/menu/native_menu_win.h b/ui/views/controls/menu/native_menu_win.h
index 91c7db5..08e07ba 100644
--- a/ui/views/controls/menu/native_menu_win.h
+++ b/ui/views/controls/menu/native_menu_win.h
@@ -15,7 +15,7 @@
#include "base/observer_list.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/views/controls/menu/menu_wrapper.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/controls/message_box_view.cc b/ui/views/controls/message_box_view.cc
index b9564fe..1c27627 100644
--- a/ui/views/controls/message_box_view.cc
+++ b/ui/views/controls/message_box_view.cc
@@ -17,9 +17,9 @@
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/client_view.h"
-#include "views/views_delegate.h"
const int kDefaultMessageWidth = 320;
diff --git a/ui/views/controls/native/native_view_host_gtk.cc b/ui/views/controls/native/native_view_host_gtk.cc
index ef706f3..b6a5042 100644
--- a/ui/views/controls/native/native_view_host_gtk.cc
+++ b/ui/views/controls/native/native_view_host_gtk.cc
@@ -11,10 +11,10 @@
#include "base/logging.h"
#include "ui/views/controls/native/native_view_host.h"
#include "ui/views/focus/focus_manager.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/gtk_views_fixed.h"
#include "ui/views/widget/native_widget_gtk.h"
#include "ui/views/widget/widget.h"
-#include "views/views_delegate.h"
namespace views {
diff --git a/ui/views/controls/native_control.cc b/ui/views/controls/native_control.cc
index 7edbda6..e09c72a 100644
--- a/ui/views/controls/native_control.cc
+++ b/ui/views/controls/native_control.cc
@@ -18,11 +18,11 @@
#include "ui/base/l10n/l10n_util_win.h"
#include "ui/base/view_prop.h"
#include "ui/base/win/hwnd_util.h"
+#include "ui/views/background.h"
+#include "ui/views/border.h"
#include "ui/views/controls/native/native_view_host.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/widget/widget.h"
-#include "views/background.h"
-#include "views/border.h"
using ui::ViewProp;
diff --git a/ui/views/controls/progress_bar.cc b/ui/views/controls/progress_bar.cc
index 74943bb..9ed1a3e 100644
--- a/ui/views/controls/progress_bar.cc
+++ b/ui/views/controls/progress_bar.cc
@@ -17,9 +17,9 @@
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h"
#include "ui/gfx/insets.h"
-#include "views/background.h"
-#include "views/border.h"
-#include "views/painter.h"
+#include "ui/views/background.h"
+#include "ui/views/border.h"
+#include "ui/views/painter.h"
namespace {
diff --git a/ui/views/controls/scrollbar/base_scroll_bar.h b/ui/views/controls/scrollbar/base_scroll_bar.h
index 09d581e..46515d5 100644
--- a/ui/views/controls/scrollbar/base_scroll_bar.h
+++ b/ui/views/controls/scrollbar/base_scroll_bar.h
@@ -10,7 +10,7 @@
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/menu/menu_delegate.h"
#include "ui/views/controls/scrollbar/scroll_bar.h"
-#include "views/repeat_controller.h"
+#include "ui/views/repeat_controller.h"
namespace views {
diff --git a/ui/views/controls/scrollbar/base_scroll_bar_button.h b/ui/views/controls/scrollbar/base_scroll_bar_button.h
index 21bea4d..ead66e3 100644
--- a/ui/views/controls/scrollbar/base_scroll_bar_button.h
+++ b/ui/views/controls/scrollbar/base_scroll_bar_button.h
@@ -8,7 +8,7 @@
#include "ui/views/controls/button/custom_button.h"
-#include "views/repeat_controller.h"
+#include "ui/views/repeat_controller.h"
#if defined(OS_LINUX)
#include "ui/gfx/screen.h"
diff --git a/ui/views/controls/scrollbar/bitmap_scroll_bar.cc b/ui/views/controls/scrollbar/bitmap_scroll_bar.cc
index 47c8f13..a8d0658 100644
--- a/ui/views/controls/scrollbar/bitmap_scroll_bar.cc
+++ b/ui/views/controls/scrollbar/bitmap_scroll_bar.cc
@@ -23,7 +23,7 @@
#include "ui/views/widget/widget.h"
#if defined(OS_LINUX)
-#include "views/screen.h"
+#include "ui/views/screen.h"
#endif
#undef min
diff --git a/ui/views/controls/scrollbar/native_scroll_bar_wrapper.h b/ui/views/controls/scrollbar/native_scroll_bar_wrapper.h
index dc8cc07..7c94a0a 100644
--- a/ui/views/controls/scrollbar/native_scroll_bar_wrapper.h
+++ b/ui/views/controls/scrollbar/native_scroll_bar_wrapper.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_WRAPPER_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/controls/scrollbar/scroll_bar.h b/ui/views/controls/scrollbar/scroll_bar.h
index 39263d6..1ed3d5c 100644
--- a/ui/views/controls/scrollbar/scroll_bar.h
+++ b/ui/views/controls/scrollbar/scroll_bar.h
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/views/view.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/controls/single_split_view.cc b/ui/views/controls/single_split_view.cc
index 333c388..94784f7 100644
--- a/ui/views/controls/single_split_view.cc
+++ b/ui/views/controls/single_split_view.cc
@@ -11,8 +11,8 @@
#include "skia/ext/skia_utils_win.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/gfx/canvas.h"
+#include "ui/views/background.h"
#include "ui/views/controls/single_split_view_listener.h"
-#include "views/background.h"
#if defined(TOOLKIT_USES_GTK)
#include "ui/gfx/gtk_util.h"
diff --git a/ui/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc b/ui/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
index 34e32ad..3afee6b 100644
--- a/ui/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
+++ b/ui/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
@@ -12,12 +12,12 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/gfx/skia_utils_gtk.h"
+#include "ui/views/background.h"
#include "ui/views/controls/tabbed_pane/tabbed_pane.h"
#include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/widget.h"
-#include "views/background.h"
namespace views {
diff --git a/ui/views/controls/table/table_view.h b/ui/views/controls/table/table_view.h
index 78a0f55..f528200 100644
--- a/ui/views/controls/table/table_view.h
+++ b/ui/views/controls/table/table_view.h
@@ -15,7 +15,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/models/table_model_observer.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
#if defined(OS_WIN)
#include <windows.h>
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index b324430..2163dbd 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -18,6 +18,8 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/render_text.h"
+#include "ui/views/background.h"
+#include "ui/views/border.h"
#include "ui/views/controls/focusable_border.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
@@ -28,10 +30,8 @@
#include "ui/views/events/event.h"
#include "ui/views/ime/input_method.h"
#include "ui/views/metrics.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
-#include "views/background.h"
-#include "views/border.h"
-#include "views/views_delegate.h"
#if defined(OS_LINUX)
#include "ui/gfx/gtk_util.h"
diff --git a/ui/views/controls/textfield/native_textfield_views.h b/ui/views/controls/textfield/native_textfield_views.h
index 8ff590c..a60b931 100644
--- a/ui/views/controls/textfield/native_textfield_views.h
+++ b/ui/views/controls/textfield/native_textfield_views.h
@@ -11,13 +11,13 @@
#include "ui/base/ime/text_input_client.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/font.h"
+#include "ui/views/border.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/controls/textfield/native_textfield_wrapper.h"
#include "ui/views/controls/textfield/textfield_views_model.h"
#include "ui/views/drag_controller.h"
#include "ui/views/touchui/touch_selection_controller.h"
#include "ui/views/view.h"
-#include "views/border.h"
namespace base {
class Time;
diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc
index ad05177..21213d2 100644
--- a/ui/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc
@@ -31,9 +31,9 @@
#include "ui/views/ime/mock_input_method.h"
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/test/views_test_base.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget_private.h"
#include "ui/views/widget/widget.h"
-#include "views/views_delegate.h"
// Drag and drop for aura in linux hasn't been implemented yet.
// Bug http://crbug.com/97845
diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc
index a8164a2..fcc782b 100644
--- a/ui/views/controls/textfield/native_textfield_win.cc
+++ b/ui/views/controls/textfield/native_textfield_win.cc
@@ -32,8 +32,8 @@
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/metrics.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
-#include "views/views_delegate.h"
namespace views {
diff --git a/ui/views/controls/textfield/native_textfield_wrapper.h b/ui/views/controls/textfield/native_textfield_wrapper.h
index 3bc3f1d..d73f893 100644
--- a/ui/views/controls/textfield/native_textfield_wrapper.h
+++ b/ui/views/controls/textfield/native_textfield_wrapper.h
@@ -8,7 +8,7 @@
#include "base/string16.h"
#include "ui/gfx/native_widget_types.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Insets;
diff --git a/ui/views/controls/textfield/textfield_views_model.cc b/ui/views/controls/textfield/textfield_views_model.cc
index 0895f91..5c50986 100644
--- a/ui/views/controls/textfield/textfield_views_model.cc
+++ b/ui/views/controls/textfield/textfield_views_model.cc
@@ -17,7 +17,7 @@
#include "ui/gfx/font.h"
#include "ui/gfx/render_text.h"
#include "ui/views/controls/textfield/textfield.h"
-#include "views/views_delegate.h"
+#include "ui/views/views_delegate.h"
namespace views {
diff --git a/ui/views/controls/textfield/textfield_views_model.h b/ui/views/controls/textfield/textfield_views_model.h
index d13a7b6d..ce1d88f 100644
--- a/ui/views/controls/textfield/textfield_views_model.h
+++ b/ui/views/controls/textfield/textfield_views_model.h
@@ -16,7 +16,7 @@
#include "ui/base/ime/composition_text.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/render_text.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class RenderText;
diff --git a/ui/views/controls/textfield/textfield_views_model_unittest.cc b/ui/views/controls/textfield/textfield_views_model_unittest.cc
index 643be1f..585d849 100644
--- a/ui/views/controls/textfield/textfield_views_model_unittest.cc
+++ b/ui/views/controls/textfield/textfield_views_model_unittest.cc
@@ -18,7 +18,7 @@
#include "ui/views/controls/textfield/textfield_views_model.h"
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/test/views_test_base.h"
-#include "views/views_delegate.h"
+#include "ui/views/views_delegate.h"
namespace {
diff --git a/ui/views/drag_controller.h b/ui/views/drag_controller.h
index 94946d7..d9f3272 100644
--- a/ui/views/drag_controller.h
+++ b/ui/views/drag_controller.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_DRAG_CONTROLLER_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Point;
diff --git a/ui/views/drag_utils.h b/ui/views/drag_utils.h
index 18098c6..cdf9e2c 100644
--- a/ui/views/drag_utils.h
+++ b/ui/views/drag_utils.h
@@ -10,7 +10,7 @@
#include "base/file_path.h"
#include "base/string16.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
class GURL;
class SkBitmap;
diff --git a/ui/views/events/event.h b/ui/views/events/event.h
index bcf57c5..c0cf2e0 100644
--- a/ui/views/events/event.h
+++ b/ui/views/events/event.h
@@ -11,7 +11,7 @@
#include "ui/base/events.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/gfx/point.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace ui {
class OSExchangeData;
diff --git a/ui/views/examples/native_theme_button_example.cc b/ui/views/examples/native_theme_button_example.cc
index 728110c..c37fc3e 100644
--- a/ui/views/examples/native_theme_button_example.cc
+++ b/ui/views/examples/native_theme_button_example.cc
@@ -16,7 +16,7 @@
#include "ui/views/controls/label.h"
#include "ui/views/examples/example_combobox_model.h"
#include "ui/views/layout/grid_layout.h"
-#include "views/native_theme_painter.h"
+#include "ui/views/native_theme_painter.h"
namespace {
diff --git a/ui/views/examples/native_theme_button_example.h b/ui/views/examples/native_theme_button_example.h
index 1e9f13b..9896818 100644
--- a/ui/views/examples/native_theme_button_example.h
+++ b/ui/views/examples/native_theme_button_example.h
@@ -11,8 +11,8 @@
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/combobox/combobox_listener.h"
#include "ui/views/examples/example_base.h"
-#include "views/native_theme_delegate.h"
-#include "views/native_theme_painter.h"
+#include "ui/views/native_theme_delegate.h"
+#include "ui/views/native_theme_painter.h"
namespace views {
class Combobox;
diff --git a/ui/views/focus/accelerator_handler.h b/ui/views/focus/accelerator_handler.h
index cd4dd71..d70c4bc 100644
--- a/ui/views/focus/accelerator_handler.h
+++ b/ui/views/focus/accelerator_handler.h
@@ -17,7 +17,7 @@
#include "base/compiler_specific.h"
#include "base/message_loop.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/focus/focus_manager.h b/ui/views/focus/focus_manager.h
index 8a9085a..0cb4671 100644
--- a/ui/views/focus/focus_manager.h
+++ b/ui/views/focus/focus_manager.h
@@ -15,7 +15,7 @@
#include "ui/base/accelerators/accelerator.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/events/event.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
// The FocusManager class is used to handle focus traversal, store/restore
// focused views and handle keyboard accelerators.
diff --git a/ui/views/focus/focus_manager_factory.h b/ui/views/focus/focus_manager_factory.h
index 7aae11d..d8da709 100644
--- a/ui/views/focus/focus_manager_factory.h
+++ b/ui/views/focus/focus_manager_factory.h
@@ -7,7 +7,7 @@
#pragma once
#include "base/basictypes.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/focus/widget_focus_manager.h b/ui/views/focus/widget_focus_manager.h
index 7a0143b..c36584b 100644
--- a/ui/views/focus/widget_focus_manager.h
+++ b/ui/views/focus/widget_focus_manager.h
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/observer_list.h"
#include "ui/gfx/native_widget_types.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
template <typename T> struct DefaultSingletonTraits;
diff --git a/ui/views/ime/input_method.h b/ui/views/ime/input_method.h
index 178b6db..310b6e1 100644
--- a/ui/views/ime/input_method.h
+++ b/ui/views/ime/input_method.h
@@ -11,7 +11,7 @@
#include "base/basictypes.h"
#include "base/i18n/rtl.h"
#include "ui/base/ime/text_input_type.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace ui {
class TextInputClient;
diff --git a/ui/views/ime/input_method_delegate.h b/ui/views/ime/input_method_delegate.h
index 369cc8b..d1a87ee 100644
--- a/ui/views/ime/input_method_delegate.h
+++ b/ui/views/ime/input_method_delegate.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_IME_INPUT_METHOD_DELEGATE_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/ime/text_input_type_tracker.h b/ui/views/ime/text_input_type_tracker.h
index 04917ee..aff74c8 100644
--- a/ui/views/ime/text_input_type_tracker.h
+++ b/ui/views/ime/text_input_type_tracker.h
@@ -9,7 +9,7 @@
#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "ui/base/ime/text_input_type.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/layout/layout_manager.h b/ui/views/layout/layout_manager.h
index 1241c80..4633544 100644
--- a/ui/views/layout/layout_manager.h
+++ b/ui/views/layout/layout_manager.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_LAYOUT_LAYOUT_MANAGER_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Size;
diff --git a/ui/views/metrics.h b/ui/views/metrics.h
index 1718ca7..62f2476 100644
--- a/ui/views/metrics.h
+++ b/ui/views/metrics.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_METRICS_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/mouse_watcher.h b/ui/views/mouse_watcher.h
index cd739d2..3ef91f3 100644
--- a/ui/views/mouse_watcher.h
+++ b/ui/views/mouse_watcher.h
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/insets.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/native_theme_delegate.h b/ui/views/native_theme_delegate.h
new file mode 100644
index 0000000..bd6051e
--- /dev/null
+++ b/ui/views/native_theme_delegate.h
@@ -0,0 +1,53 @@
+// 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 UI_VIEWS_NATIVE_THEME_DELEGATE_H_
+#define UI_VIEWS_NATIVE_THEME_DELEGATE_H_
+#pragma once
+
+#include "ui/gfx/native_theme.h"
+#include "ui/gfx/rect.h"
+#include "ui/views/views_export.h"
+
+namespace views {
+
+// A delagate that supports animating transtions between different native
+// theme states. This delegate can be used to control a native theme Border
+// or Painter object.
+//
+// If animation is onging, the native theme border or painter will
+// composite the foreground state over the backgroud state using an alpha
+// between 0 and 255 based on the current value of the animation.
+class VIEWS_EXPORT NativeThemeDelegate {
+ public:
+ virtual ~NativeThemeDelegate() {}
+
+ // Get the native theme part that should be drawn.
+ virtual gfx::NativeTheme::Part GetThemePart() const = 0;
+
+ // Get the rectangle that should be painted.
+ virtual gfx::Rect GetThemePaintRect() const = 0;
+
+ // Get the state of the part, along with any extra data needed for drawing.
+ virtual gfx::NativeTheme::State GetThemeState(
+ gfx::NativeTheme::ExtraParams* params) const = 0;
+
+ // If the native theme drawign should be animated, return the Animation object
+ // that controlls it. If no animation is ongoing, NULL may be returned.
+ virtual const ui::Animation* GetThemeAnimation() const = 0;
+
+ // If animation is onging, this returns the background native theme state.
+ virtual gfx::NativeTheme::State GetBackgroundThemeState(
+ gfx::NativeTheme::ExtraParams* params) const = 0;
+
+ // If animation is onging, this returns the foreground native theme state.
+ // This state will be composited over the background using an alpha value
+ // based on the current value of the animation.
+ virtual gfx::NativeTheme::State GetForegroundThemeState(
+ gfx::NativeTheme::ExtraParams* params) const = 0;
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_NATIVE_THEME_DELEGATE_H_
diff --git a/ui/views/native_theme_painter.cc b/ui/views/native_theme_painter.cc
new file mode 100644
index 0000000..30299ac
--- /dev/null
+++ b/ui/views/native_theme_painter.cc
@@ -0,0 +1,56 @@
+// 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 "ui/views/native_theme_painter.h"
+
+#include "base/logging.h"
+#include "ui/base/animation/animation.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/canvas_skia.h"
+#include "ui/gfx/rect.h"
+#include "ui/views/native_theme_delegate.h"
+
+namespace views {
+
+NativeThemePainter::NativeThemePainter(NativeThemeDelegate* delegate)
+ : delegate_(delegate) {
+ DCHECK(delegate_);
+}
+
+gfx::Size NativeThemePainter::GetPreferredSize() {
+ const gfx::NativeTheme* theme = gfx::NativeTheme::instance();
+ gfx::NativeTheme::ExtraParams extra;
+ gfx::NativeTheme::State state = delegate_->GetThemeState(&extra);
+ return theme->GetPartSize(delegate_->GetThemePart(), state, extra);
+}
+
+void NativeThemePainter::Paint(int w, int h, gfx::Canvas* canvas) {
+ const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance();
+ gfx::NativeTheme::Part part = delegate_->GetThemePart();
+ gfx::Rect rect(0, 0, w, h);
+
+ if (delegate_->GetThemeAnimation() != NULL &&
+ delegate_->GetThemeAnimation()->is_animating()) {
+ // Paint background state.
+ gfx::NativeTheme::ExtraParams prev_extra;
+ gfx::NativeTheme::State prev_state =
+ delegate_->GetBackgroundThemeState(&prev_extra);
+ native_theme->Paint(
+ canvas->GetSkCanvas(), part, prev_state, rect, prev_extra);
+
+ // Composite foreground state above it.
+ gfx::NativeTheme::ExtraParams extra;
+ gfx::NativeTheme::State state = delegate_->GetForegroundThemeState(&extra);
+ int alpha = delegate_->GetThemeAnimation()->CurrentValueBetween(0, 255);
+ canvas->SaveLayerAlpha(static_cast<uint8>(alpha));
+ native_theme->Paint(canvas->GetSkCanvas(), part, state, rect, extra);
+ canvas->Restore();
+ } else {
+ gfx::NativeTheme::ExtraParams extra;
+ gfx::NativeTheme::State state = delegate_->GetThemeState(&extra);
+ native_theme->Paint(canvas->GetSkCanvas(), part, state, rect, extra);
+ }
+}
+
+} // namespace views
diff --git a/ui/views/native_theme_painter.h b/ui/views/native_theme_painter.h
new file mode 100644
index 0000000..f21b731
--- /dev/null
+++ b/ui/views/native_theme_painter.h
@@ -0,0 +1,45 @@
+// 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 UI_VIEWS_NATIVE_THEME_PAINTER_H_
+#define UI_VIEWS_NATIVE_THEME_PAINTER_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "ui/views/painter.h"
+
+namespace gfx {
+class Canvas;
+class Size;
+}
+
+namespace views {
+
+class NativeThemeDelegate;
+
+// A Painter that uses NativeTheme to implement painting and sizing. A
+// theme delegate must be given at construction time so that the appropriate
+// painting and sizing can be done.
+class VIEWS_EXPORT NativeThemePainter : public Painter {
+ public:
+ explicit NativeThemePainter(NativeThemeDelegate* delegate);
+
+ virtual ~NativeThemePainter() {}
+
+ // Returns the preferred size of the native part being painted.
+ gfx::Size GetPreferredSize();
+
+ private:
+ // The delegate the controls the appearance of this painter.
+ NativeThemeDelegate* delegate_;
+
+ // Overridden from Painter:
+ virtual void Paint(int w, int h, gfx::Canvas* canvas) OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(NativeThemePainter);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_NATIVE_THEME_PAINTER_H_
diff --git a/ui/views/paint_lock.cc b/ui/views/paint_lock.cc
new file mode 100644
index 0000000..0da6386
--- /dev/null
+++ b/ui/views/paint_lock.cc
@@ -0,0 +1,19 @@
+// 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 "ui/views/paint_lock.h"
+
+#include "ui/views/view.h"
+
+namespace views {
+
+PaintLock::PaintLock(View* view) : view_(view) {
+ view_->set_painting_enabled(false);
+}
+
+PaintLock::~PaintLock() {
+ view_->set_painting_enabled(true);
+}
+
+} // namespace views
diff --git a/ui/views/paint_lock.h b/ui/views/paint_lock.h
new file mode 100644
index 0000000..41e3083
--- /dev/null
+++ b/ui/views/paint_lock.h
@@ -0,0 +1,36 @@
+// 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 UI_VIEWS_PAINT_LOCK_H_
+#define UI_VIEWS_PAINT_LOCK_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "ui/views/views_export.h"
+
+namespace views {
+
+class View;
+
+// Instances of PaintLock can be created to disable painting of the view
+// (compositing is not disabled). When the class is destroyed, painting is
+// re-enabled. This can be useful during operations like animations, that are
+// sensitive to costly paints, and during which only composting, not painting,
+// is required.
+class VIEWS_EXPORT PaintLock {
+ public:
+ // The paint lock does not own the view. It is an error for the view to be
+ // destroyed before the lock.
+ PaintLock(View* view);
+ ~PaintLock();
+
+ private:
+ View* view_;
+
+ DISALLOW_COPY_AND_ASSIGN(PaintLock);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_PAINT_LOCK_H_
diff --git a/ui/views/painter.cc b/ui/views/painter.cc
new file mode 100644
index 0000000..ef5cfbf
--- /dev/null
+++ b/ui/views/painter.cc
@@ -0,0 +1,199 @@
+// 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 "ui/views/painter.h"
+
+#include "base/logging.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/effects/SkGradientShader.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/canvas_skia.h"
+#include "ui/gfx/insets.h"
+#include "ui/gfx/point.h"
+
+namespace views {
+
+namespace {
+
+class GradientPainter : public Painter {
+ public:
+ GradientPainter(bool horizontal, const SkColor& top, const SkColor& bottom)
+ : horizontal_(horizontal) {
+ colors_[0] = top;
+ colors_[1] = bottom;
+ }
+
+ virtual ~GradientPainter() {
+ }
+
+ void Paint(int w, int h, gfx::Canvas* canvas) {
+ SkPaint paint;
+ SkPoint p[2];
+ p[0].set(SkIntToScalar(0), SkIntToScalar(0));
+ if (horizontal_)
+ p[1].set(SkIntToScalar(w), SkIntToScalar(0));
+ else
+ p[1].set(SkIntToScalar(0), SkIntToScalar(h));
+
+ SkShader* s =
+ SkGradientShader::CreateLinear(p, colors_, NULL, 2,
+ SkShader::kClamp_TileMode, NULL);
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setShader(s);
+ // Need to unref shader, otherwise never deleted.
+ s->unref();
+
+ canvas->GetSkCanvas()->drawRectCoords(
+ SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(w), SkIntToScalar(h),
+ paint);
+ }
+
+ private:
+ bool horizontal_;
+ SkColor colors_[2];
+
+ DISALLOW_COPY_AND_ASSIGN(GradientPainter);
+};
+
+
+class ImagePainter : public Painter {
+ public:
+ ImagePainter(const SkBitmap& image,
+ const gfx::Insets& insets,
+ bool paint_center)
+ : image_(image),
+ insets_(insets),
+ paint_center_(paint_center) {
+ DCHECK(image.width() > insets.width() &&
+ image.height() > insets.height());
+ }
+
+ // Paints the images.
+ virtual void Paint(int w, int h, gfx::Canvas* canvas) {
+ if (w == image_.width() && h == image_.height()) {
+ // Early out if the size we're to render at equals the size of the image.
+ canvas->DrawBitmapInt(image_, 0, 0);
+ return;
+ }
+ // Upper left.
+ canvas->DrawBitmapInt(image_, 0, 0, insets_.left(), insets_.top(),
+ 0, 0, insets_.left(), insets_.top(), true);
+ // Top edge.
+ canvas->DrawBitmapInt(
+ image_,
+ insets_.left(), 0, image_.width() - insets_.width(), insets_.top(),
+ insets_.left(), 0, w - insets_.width(), insets_.top(), true);
+ // Upper right.
+ canvas->DrawBitmapInt(
+ image_,
+ image_.width() - insets_.right(), 0, insets_.right(), insets_.top(),
+ w - insets_.right(), 0, insets_.right(), insets_.top(), true);
+ // Right edge.
+ canvas->DrawBitmapInt(
+ image_,
+ image_.width() - insets_.right(), insets_.top(),
+ insets_.right(), image_.height() - insets_.height(),
+ w - insets_.right(), insets_.top(), insets_.right(),
+ h - insets_.height(), true);
+ // Bottom right.
+ canvas->DrawBitmapInt(
+ image_,
+ image_.width() - insets_.right(), image_.height() - insets_.bottom(),
+ insets_.right(), insets_.bottom(),
+ w - insets_.right(), h - insets_.bottom(), insets_.right(),
+ insets_.bottom(), true);
+ // Bottom edge.
+ canvas->DrawBitmapInt(
+ image_,
+ insets_.left(), image_.height() - insets_.bottom(),
+ image_.width() - insets_.width(), insets_.bottom(),
+ insets_.left(), h - insets_.bottom(), w - insets_.width(),
+ insets_.bottom(), true);
+ // Bottom left.
+ canvas->DrawBitmapInt(
+ image_,
+ 0, image_.height() - insets_.bottom(), insets_.left(),
+ insets_.bottom(),
+ 0, h - insets_.bottom(), insets_.left(), insets_.bottom(), true);
+ // Left.
+ canvas->DrawBitmapInt(
+ image_,
+ 0, insets_.top(), insets_.left(), image_.height() - insets_.height(),
+ 0, insets_.top(), insets_.left(), h - insets_.height(), true);
+ // Center.
+ if (paint_center_) {
+ canvas->DrawBitmapInt(
+ image_,
+ insets_.left(), insets_.top(),
+ image_.width() - insets_.width(), image_.height() - insets_.height(),
+ insets_.left(), insets_.top(),
+ w - insets_.width(), h - insets_.height(), true);
+ }
+ }
+
+ private:
+ const SkBitmap image_;
+ const gfx::Insets insets_;
+ bool paint_center_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImagePainter);
+};
+
+} // namespace
+
+// static
+void Painter::PaintPainterAt(int x, int y, int w, int h,
+ gfx::Canvas* canvas, Painter* painter) {
+ DCHECK(canvas && painter);
+ if (w < 0 || h < 0)
+ return;
+ canvas->Save();
+ canvas->Translate(gfx::Point(x, y));
+ painter->Paint(w, h, canvas);
+ canvas->Restore();
+}
+
+// static
+Painter* Painter::CreateHorizontalGradient(SkColor c1, SkColor c2) {
+ return new GradientPainter(true, c1, c2);
+}
+
+// static
+Painter* Painter::CreateVerticalGradient(SkColor c1, SkColor c2) {
+ return new GradientPainter(false, c1, c2);
+}
+
+// static
+Painter* Painter::CreateImagePainter(const SkBitmap& image,
+ const gfx::Insets& insets,
+ bool paint_center) {
+ return new ImagePainter(image, insets, paint_center);
+}
+
+HorizontalPainter::HorizontalPainter(const int image_resource_names[]) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ for (int i = 0; i < 3; ++i)
+ images_[i] = rb.GetBitmapNamed(image_resource_names[i]);
+ height_ = images_[LEFT]->height();
+ DCHECK(images_[LEFT]->height() == images_[RIGHT]->height() &&
+ images_[LEFT]->height() == images_[CENTER]->height());
+}
+
+void HorizontalPainter::Paint(int w, int h, gfx::Canvas* canvas) {
+ if (w < (images_[LEFT]->width() + images_[CENTER]->width() +
+ images_[RIGHT]->width())) {
+ // No room to paint.
+ return;
+ }
+ canvas->DrawBitmapInt(*images_[LEFT], 0, 0);
+ canvas->DrawBitmapInt(*images_[RIGHT], w - images_[RIGHT]->width(), 0);
+ canvas->TileImageInt(*images_[CENTER],
+ images_[LEFT]->width(),
+ 0,
+ w - images_[LEFT]->width() - images_[RIGHT]->width(),
+ height_);
+}
+
+} // namespace views
diff --git a/ui/views/painter.h b/ui/views/painter.h
new file mode 100644
index 0000000..575eae9
--- /dev/null
+++ b/ui/views/painter.h
@@ -0,0 +1,88 @@
+// 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 UI_VIEWS_PAINTER_H_
+#define UI_VIEWS_PAINTER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/views/views_export.h"
+
+namespace gfx {
+class Canvas;
+class Insets;
+}
+class SkBitmap;
+
+namespace views {
+
+// Painter, as the name implies, is responsible for painting in a particular
+// region. Think of Painter as a Border or Background that can be painted
+// in any region of a View.
+class VIEWS_EXPORT Painter {
+ public:
+ // A convenience method for painting a Painter in a particular region.
+ // This translates the canvas to x/y and paints the painter.
+ static void PaintPainterAt(int x, int y, int w, int h,
+ gfx::Canvas* canvas, Painter* painter);
+
+ // Creates a painter that draws a gradient between the two colors.
+ static Painter* CreateHorizontalGradient(SkColor c1, SkColor c2);
+ static Painter* CreateVerticalGradient(SkColor c1, SkColor c2);
+
+ // Creates a painter that divides |image| into nine regions. The four corners
+ // are rendered at the size specified in insets (for example, the upper
+ // left corners is rendered at 0x0 with a size of
+ // insets.left()xinsets.right()). The four edges are stretched to fill the
+ // destination size.
+ // Ownership is passed to the caller.
+ static Painter* CreateImagePainter(const SkBitmap& image,
+ const gfx::Insets& insets,
+ bool paint_center);
+
+ virtual ~Painter() {}
+
+ // Paints the painter in the specified region.
+ virtual void Paint(int w, int h, gfx::Canvas* canvas) = 0;
+};
+
+// HorizontalPainter paints 3 images into a box: left, center and right. The
+// left and right images are drawn to size at the left/right edges of the
+// region. The center is tiled in the remaining space. All images must have the
+// same height.
+class VIEWS_EXPORT HorizontalPainter : public Painter {
+ public:
+ // Constructs a new HorizontalPainter loading the specified image names.
+ // The images must be in the order left, right and center.
+ explicit HorizontalPainter(const int image_resource_names[]);
+
+ virtual ~HorizontalPainter() {}
+
+ // Paints the images.
+ virtual void Paint(int w, int h, gfx::Canvas* canvas) OVERRIDE;
+
+ // Height of the images.
+ int height() const { return height_; }
+
+ private:
+ // The image chunks.
+ enum BorderElements {
+ LEFT,
+ CENTER,
+ RIGHT
+ };
+
+ // The height.
+ int height_;
+ // NOTE: the images are owned by ResourceBundle. Don't free them.
+ SkBitmap* images_[3];
+
+ DISALLOW_COPY_AND_ASSIGN(HorizontalPainter);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_PAINTER_H_
diff --git a/ui/views/repeat_controller.cc b/ui/views/repeat_controller.cc
new file mode 100644
index 0000000..dd90aaa
--- /dev/null
+++ b/ui/views/repeat_controller.cc
@@ -0,0 +1,45 @@
+// 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 "ui/views/repeat_controller.h"
+
+using base::TimeDelta;
+
+namespace views {
+
+// The delay before the first and then subsequent repeats. Values taken from
+// XUL code: http://mxr.mozilla.org/seamonkey/source/layout/xul/base/src/nsRepeatService.cpp#52
+const int kInitialRepeatDelay = 250;
+const int kRepeatDelay = 50;
+
+///////////////////////////////////////////////////////////////////////////////
+// RepeatController, public:
+
+RepeatController::RepeatController(const base::Closure& callback)
+ : callback_(callback) {
+}
+
+RepeatController::~RepeatController() {
+}
+
+void RepeatController::Start() {
+ // The first timer is slightly longer than subsequent repeats.
+ timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(kInitialRepeatDelay),
+ this, &RepeatController::Run);
+}
+
+void RepeatController::Stop() {
+ timer_.Stop();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// RepeatController, private:
+
+void RepeatController::Run() {
+ timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(kRepeatDelay), this,
+ &RepeatController::Run);
+ callback_.Run();
+}
+
+} // namespace views
diff --git a/ui/views/repeat_controller.h b/ui/views/repeat_controller.h
new file mode 100644
index 0000000..1efe50e4
--- /dev/null
+++ b/ui/views/repeat_controller.h
@@ -0,0 +1,50 @@
+// 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 UI_VIEWS_REPEAT_CONTROLLER_H_
+#define UI_VIEWS_REPEAT_CONTROLLER_H_
+#pragma once
+
+#include "base/callback.h"
+#include "base/timer.h"
+
+namespace views {
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// RepeatController
+//
+// An object that handles auto-repeating UI actions. There is a longer initial
+// delay after which point repeats become constant. Users provide a callback
+// that is notified when each repeat occurs so that they can perform the
+// associated action.
+//
+///////////////////////////////////////////////////////////////////////////////
+class RepeatController {
+ public:
+ // The RepeatController takes ownership of this callback object.
+ explicit RepeatController(const base::Closure& callback);
+ virtual ~RepeatController();
+
+ // Start repeating.
+ void Start();
+
+ // Stop repeating.
+ void Stop();
+
+ private:
+ // Called when the timer expires.
+ void Run();
+
+ // The current timer.
+ base::OneShotTimer<RepeatController> timer_;
+
+ base::Closure callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(RepeatController);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_REPEAT_CONTROLLER_H_
diff --git a/ui/views/run_all_unittests.cc b/ui/views/run_all_unittests.cc
new file mode 100644
index 0000000..e675291
--- /dev/null
+++ b/ui/views/run_all_unittests.cc
@@ -0,0 +1,34 @@
+// 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 "base/test/test_suite.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/gfx/compositor/test/compositor_test_support.h"
+#include "ui/gfx/test/gfx_test_utils.h"
+#include "ui/views/view.h"
+
+class ViewTestSuite : public base::TestSuite {
+ public:
+ ViewTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {}
+
+ protected:
+ virtual void Initialize() {
+ base::TestSuite::Initialize();
+
+ ui::RegisterPathProvider();
+ ui::ResourceBundle::InitSharedInstance("en-US");
+
+ ui::CompositorTestSupport::Initialize();
+ ui::gfx_test_utils::SetupTestCompositor();
+ }
+
+ virtual void Shutdown() {
+ ui::CompositorTestSupport::Terminate();
+ }
+};
+
+int main(int argc, char** argv) {
+ return ViewTestSuite(argc, argv).Run();
+}
diff --git a/ui/views/test/test_views_delegate.h b/ui/views/test/test_views_delegate.h
index 7812701..f2c8f69 100644
--- a/ui/views/test/test_views_delegate.h
+++ b/ui/views/test/test_views_delegate.h
@@ -10,7 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "ui/base/accessibility/accessibility_types.h"
-#include "views/views_delegate.h"
+#include "ui/views/views_delegate.h"
namespace ui {
class Clipboard;
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc
index 894c8a4..906a605 100644
--- a/ui/views/touchui/touch_selection_controller_impl.cc
+++ b/ui/views/touchui/touch_selection_controller_impl.cc
@@ -17,6 +17,7 @@
#include "ui/gfx/screen.h"
#include "ui/gfx/size.h"
#include "ui/gfx/transform.h"
+#include "ui/views/background.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/button/text_button.h"
@@ -24,7 +25,6 @@
#include "ui/views/controls/menu/menu_config.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h"
-#include "views/background.h"
namespace {
diff --git a/ui/views/touchui/touch_selection_controller_impl.h b/ui/views/touchui/touch_selection_controller_impl.h
index f0d5a5d..7e8eff4 100644
--- a/ui/views/touchui/touch_selection_controller_impl.h
+++ b/ui/views/touchui/touch_selection_controller_impl.h
@@ -10,7 +10,7 @@
#include "ui/gfx/point.h"
#include "ui/views/touchui/touch_selection_controller.h"
#include "ui/views/view.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace views {
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 09d3cbe..9179375 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -23,15 +23,15 @@
#include "ui/gfx/path.h"
#include "ui/gfx/point3.h"
#include "ui/gfx/transform.h"
+#include "ui/views/background.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/drag_controller.h"
#include "ui/views/layout/layout_manager.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget_private.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/tooltip_manager.h"
#include "ui/views/widget/widget.h"
-#include "views/background.h"
-#include "views/views_delegate.h"
#if defined(OS_WIN)
#include "base/win/scoped_gdi_object.h"
diff --git a/ui/views/view.h b/ui/views/view.h
index 6e8eb28..d6e6ca9 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -22,9 +22,9 @@
#include "ui/gfx/compositor/layer_delegate.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
+#include "ui/views/background.h"
+#include "ui/views/border.h"
#include "ui/views/events/event.h"
-#include "views/background.h"
-#include "views/border.h"
#if defined(OS_WIN)
#include "base/win/scoped_comptr.h"
diff --git a/ui/views/view_constants.cc b/ui/views/view_constants.cc
new file mode 100644
index 0000000..63a5a22
--- /dev/null
+++ b/ui/views/view_constants.cc
@@ -0,0 +1,13 @@
+// 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 "ui/views/view_constants.h"
+
+namespace views {
+
+const int kAutoscrollSize = 10;
+const int kAutoscrollRowTimerMS = 200;
+const int kDropBetweenPixels = 5;
+
+} // namespace views
diff --git a/ui/views/view_constants.h b/ui/views/view_constants.h
new file mode 100644
index 0000000..96f07c4
--- /dev/null
+++ b/ui/views/view_constants.h
@@ -0,0 +1,28 @@
+// 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 UI_VIEWS_VIEW_CONSTANTS_H_
+#define UI_VIEWS_VIEW_CONSTANTS_H_
+#pragma once
+
+#include "ui/views/views_export.h"
+
+namespace views {
+
+// Size (width or height) within which the user can hold the mouse and the
+// view should scroll.
+VIEWS_EXPORT extern const int kAutoscrollSize;
+
+// Time in milliseconds to autoscroll by a row. This is used during drag and
+// drop.
+VIEWS_EXPORT extern const int kAutoscrollRowTimerMS;
+
+// Used to determine whether a drop is on an item or before/after it. If a drop
+// occurs kDropBetweenPixels from the top/bottom it is considered before/after
+// the item, otherwise it is on the item.
+VIEWS_EXPORT extern const int kDropBetweenPixels;
+
+} // namespace views
+
+#endif // UI_VIEWS_VIEW_CONSTANTS_H_
diff --git a/ui/views/view_text_utils.cc b/ui/views/view_text_utils.cc
new file mode 100644
index 0000000..ebd787ea
--- /dev/null
+++ b/ui/views/view_text_utils.cc
@@ -0,0 +1,164 @@
+// 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 "ui/views/view_text_utils.h"
+
+#include "base/i18n/bidi_line_iterator.h"
+#include "base/i18n/break_iterator.h"
+#include "base/logging.h"
+#include "base/utf_string_conversions.h"
+#include "ui/gfx/canvas_skia.h"
+#include "ui/gfx/font.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/size.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/controls/link.h"
+
+namespace view_text_utils {
+
+void DrawTextAndPositionUrl(gfx::Canvas* canvas,
+ views::Label* label,
+ const string16& text,
+ views::Link* link,
+ gfx::Rect* rect,
+ gfx::Size* position,
+ bool text_direction_is_rtl,
+ const gfx::Rect& bounds,
+ const gfx::Font& font) {
+ DCHECK(canvas && position);
+
+ // The |text| parameter is potentially a mix of LTR and RTL "runs," where
+ // a run is a sequence of words that share the same directionality. We
+ // initialize a bidirectional ICU line iterator and split the text into
+ // runs that are either strictly LTR or strictly RTL, with no mix.
+ base::i18n::BiDiLineIterator bidi_line;
+ if (!bidi_line.Open(text, true, false))
+ return;
+
+ // Iterate over each run and draw it.
+ int run_start = 0;
+ int run_end = 0;
+ const int runs = bidi_line.CountRuns();
+ for (int run = 0; run < runs; ++run) {
+ UBiDiLevel level = 0;
+ bidi_line.GetLogicalRun(run_start, &run_end, &level);
+ DCHECK(run_end > run_start);
+ string16 fragment = text.substr(run_start, run_end - run_start);
+
+ // A flag that tells us whether we found LTR text inside RTL text.
+ bool ltr_inside_rtl_text =
+ ((level & 1) == UBIDI_LTR) && text_direction_is_rtl;
+
+ // Draw text chunk contained in |fragment|. |position| is relative to the
+ // top left corner of the label we draw inside, even when drawing RTL.
+ DrawTextStartingFrom(canvas, label, fragment, position, bounds, font,
+ text_direction_is_rtl, ltr_inside_rtl_text);
+
+ run_start = run_end; // Advance over what we just drew.
+ }
+
+ // If the caller is interested in placing a link after this text blurb, we
+ // figure out here where to place it.
+ if (link && rect) {
+ gfx::Size sz = link->GetPreferredSize();
+ gfx::Insets insets = link->GetInsets();
+ WrapIfWordDoesntFit(sz.width(), font.GetHeight(), position, bounds);
+ int x = position->width();
+ int y = position->height();
+
+ // Links have a border to allow them to be focused.
+ y -= insets.top();
+
+ *rect = gfx::Rect(x, y, sz.width(), sz.height());
+
+ // Go from relative pixel coordinates (within the label we are drawing
+ // on) to absolute pixel coordinates (relative to the top left corner of
+ // the dialog content).
+ rect->Offset(bounds.x(), bounds.y());
+ // And leave some space to draw the link in.
+ position->Enlarge(sz.width(), 0);
+ }
+}
+
+void DrawTextStartingFrom(gfx::Canvas* canvas,
+ views::Label* label,
+ const string16& text,
+ gfx::Size* position,
+ const gfx::Rect& bounds,
+ const gfx::Font& font,
+ bool text_direction_is_rtl,
+ bool ltr_within_rtl) {
+ // Iterate through line breaking opportunities (which in English would be
+ // spaces and such). This tells us where to wrap.
+ string16 text16(text);
+ base::i18n::BreakIterator iter(text16,
+ base::i18n::BreakIterator::BREAK_SPACE);
+ if (!iter.Init())
+ return;
+
+ int flags = (text_direction_is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT :
+ gfx::Canvas::TEXT_ALIGN_LEFT);
+ flags |= gfx::Canvas::MULTI_LINE | gfx::Canvas::HIDE_PREFIX;
+
+ // Iterate over each word in the text, or put in a more locale-neutral way:
+ // iterate to the next line breaking opportunity.
+ while (iter.Advance()) {
+ // Get the word and figure out the dimensions.
+ string16 word;
+ if (!ltr_within_rtl)
+ word = iter.GetString(); // Get the next word.
+ else
+ word = text16; // Draw the whole text at once.
+
+ int w = font.GetStringWidth(word), h = font.GetHeight();
+ gfx::CanvasSkia::SizeStringInt(word, font, &w, &h, flags);
+
+ // If we exceed the boundaries, we need to wrap.
+ WrapIfWordDoesntFit(w, font.GetHeight(), position, bounds);
+
+ int x = label->GetMirroredXInView(position->width()) + bounds.x();
+ if (text_direction_is_rtl) {
+ x -= w;
+ // When drawing LTR strings inside RTL text we need to make sure we
+ // draw the trailing space (if one exists after the LTR text) to the
+ // left of the LTR string.
+ if (ltr_within_rtl && word[word.size() - 1] == ' ') {
+ int space_w = font.GetStringWidth(ASCIIToUTF16(" "));
+ int space_h = font.GetHeight();
+ gfx::CanvasSkia::SizeStringInt(ASCIIToUTF16(" "), font, &space_w,
+ &space_h, flags);
+ x += space_w;
+ }
+ }
+ int y = position->height() + bounds.y();
+
+ // Draw the text on the screen (mirrored, if RTL run).
+ canvas->DrawStringInt(word, font, label->enabled_color(), x, y, w,
+ font.GetHeight(), flags);
+
+ if (!word.empty() && word[word.size() - 1] == '\x0a') {
+ // When we come across '\n', we move to the beginning of the next line.
+ position->set_width(0);
+ position->Enlarge(0, font.GetHeight());
+ } else {
+ // Otherwise, we advance position to the next word.
+ position->Enlarge(w, 0);
+ }
+
+ if (ltr_within_rtl)
+ break; // LTR within RTL is drawn as one unit, so we are done.
+ }
+}
+
+void WrapIfWordDoesntFit(int word_width,
+ int font_height,
+ gfx::Size* position,
+ const gfx::Rect& bounds) {
+ if (position->width() + word_width > bounds.right()) {
+ position->set_width(0);
+ position->Enlarge(0, font_height);
+ }
+}
+
+} // namespace view_text_utils
diff --git a/ui/views/view_text_utils.h b/ui/views/view_text_utils.h
new file mode 100644
index 0000000..c0141a5
--- /dev/null
+++ b/ui/views/view_text_utils.h
@@ -0,0 +1,76 @@
+// 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 UI_VIEWS_VIEW_TEXT_UTILS_H_
+#define UI_VIEWS_VIEW_TEXT_UTILS_H_
+#pragma once
+
+#include "base/string16.h"
+#include "ui/views/views_export.h"
+
+namespace gfx {
+class Canvas;
+class Font;
+class Rect;
+class Size;
+}
+
+namespace views {
+class Label;
+class Link;
+}
+
+// This file defines utility functions for working with text in views.
+
+namespace view_text_utils {
+
+// Draws a string onto the canvas (wrapping if needed) while also keeping
+// track of where it ends so we can position a URL after the text. The
+// parameter |bounds| represents the boundary we have to work with, |position|
+// specifies where to draw the string (relative to the top left corner of the
+// |bounds| rectangle and |font| specifies the font to use when drawing. When
+// the function returns, the parameter |rect| contains where to draw the URL
+// (to the right of where we just drew the text) and |position| is updated to
+// reflect where to draw the next string after the URL. |label| is a dummy
+// label with the correct width and origin for the text to be written; it's
+// used so that the x position can be correctly mirrored in RTL languages.
+// |text_direction_is_rtl| is true if an RTL language is being used.
+// NOTE: The reason why we need this function is because while Skia knows how
+// to wrap text appropriately, it doesn't tell us where it drew the last
+// character, which we need to position the URLs within the text.
+VIEWS_EXPORT void DrawTextAndPositionUrl(gfx::Canvas* canvas,
+ views::Label* label,
+ const string16& text,
+ views::Link* link,
+ gfx::Rect* rect,
+ gfx::Size* position,
+ bool text_direction_is_rtl,
+ const gfx::Rect& bounds,
+ const gfx::Font& font);
+
+// A helper function for DrawTextAndPositionUrl, which simply draws the text
+// from a certain starting point |position| and wraps within bounds.
+// |word_for_word| specifies whether to draw the text word for word or whether
+// to treat the text as one blurb (similar to the way URL's are treated inside
+// RTL text. For details on the other parameters, see DrawTextAndPositionUrl.
+void DrawTextStartingFrom(gfx::Canvas* canvas,
+ views::Label* label,
+ const string16& text,
+ gfx::Size* position,
+ const gfx::Rect& bounds,
+ const gfx::Font& font,
+ bool text_direction_is_rtl,
+ bool word_for_word);
+
+// A simply utility function that calculates whether a word of width
+// |word_width| fits at position |position| within the |bounds| rectangle. If
+// not, |position| is updated to wrap to the beginning of the next line.
+void WrapIfWordDoesntFit(int word_width,
+ int font_height,
+ gfx::Size* position,
+ const gfx::Rect& bounds);
+
+} // namespace view_text_utils
+
+#endif // UI_VIEWS_VIEW_TEXT_UTILS_H_
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index e64fae6..224b5c9c 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -21,6 +21,7 @@
#include "ui/gfx/compositor/test/test_texture.h"
#include "ui/gfx/path.h"
#include "ui/gfx/transform.h"
+#include "ui/views/background.h"
#include "ui/views/controls/button/button_dropdown.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/native/native_view_host.h"
@@ -32,11 +33,10 @@
#include "ui/views/test/views_test_base.h"
#include "ui/views/touchui/gesture_manager.h"
#include "ui/views/view.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/window/dialog_delegate.h"
-#include "views/background.h"
-#include "views/views_delegate.h"
#if defined(OS_WIN)
#include "ui/views/test/test_views_delegate.h"
diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h
new file mode 100644
index 0000000..6194617d
--- /dev/null
+++ b/ui/views/views_delegate.h
@@ -0,0 +1,91 @@
+// 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 UI_VIEWS_VIEWS_DELEGATE_H_
+#define UI_VIEWS_VIEWS_DELEGATE_H_
+#pragma once
+
+#include <string>
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
+#include "base/string16.h"
+#include "ui/base/accessibility/accessibility_types.h"
+#include "ui/base/ui_base_types.h"
+#include "ui/views/views_export.h"
+
+namespace gfx {
+class Rect;
+}
+
+namespace ui {
+class Clipboard;
+}
+
+namespace views {
+
+class View;
+class Widget;
+
+// ViewsDelegate is an interface implemented by an object using the views
+// framework. It is used to obtain various high level application utilities
+// and perform some actions such as window placement saving.
+//
+// The embedding app must set views_delegate to assign its ViewsDelegate
+// implementation.
+class VIEWS_EXPORT ViewsDelegate {
+ public:
+ // The active ViewsDelegate used by the views system.
+ static ViewsDelegate* views_delegate;
+
+ virtual ~ViewsDelegate() {}
+
+ // Gets the clipboard.
+ virtual ui::Clipboard* GetClipboard() const = 0;
+
+ // Saves the position, size and "show" state for the window with the
+ // specified name.
+ virtual void SaveWindowPlacement(const Widget* widget,
+ const std::string& window_name,
+ const gfx::Rect& bounds,
+ ui::WindowShowState show_state) = 0;
+
+ // Retrieves the saved position and size and "show" state for the window with
+ // the specified name.
+ virtual bool GetSavedWindowPlacement(
+ const std::string& window_name,
+ gfx::Rect* bounds,
+ ui::WindowShowState* show_state) const = 0;
+
+ virtual void NotifyAccessibilityEvent(
+ View* view,
+ ui::AccessibilityTypes::Event event_type) = 0;
+
+ // For accessibility, notify the delegate that a menu item was focused
+ // so that alternate feedback (speech / magnified text) can be provided.
+ virtual void NotifyMenuItemFocused(const string16& menu_name,
+ const string16& menu_item_name,
+ int item_index,
+ int item_count,
+ bool has_submenu) = 0;
+
+#if defined(OS_WIN)
+ // Retrieves the default window icon to use for windows if none is specified.
+ virtual HICON GetDefaultWindowIcon() const = 0;
+#endif
+
+ // AddRef/ReleaseRef are invoked while a menu is visible. They are used to
+ // ensure we don't attempt to exit while a menu is showing.
+ virtual void AddRef() = 0;
+ virtual void ReleaseRef() = 0;
+
+ // Converts views::Event::flags to a WindowOpenDisposition.
+ virtual int GetDispositionForEvent(int event_flags) = 0;
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_VIEWS_DELEGATE_H_
diff --git a/ui/views/views_export.h b/ui/views/views_export.h
new file mode 100644
index 0000000..f77ac98
--- /dev/null
+++ b/ui/views/views_export.h
@@ -0,0 +1,29 @@
+// 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 UI_VIEWS_VIEWS_EXPORT_H_
+#define UI_VIEWS_VIEWS_EXPORT_H_
+#pragma once
+
+// Defines VIEWS_EXPORT so that functionality implemented by the Views module
+// can be exported to consumers.
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(VIEWS_IMPLEMENTATION)
+#define VIEWS_EXPORT __declspec(dllexport)
+#else
+#define VIEWS_EXPORT __declspec(dllimport)
+#endif // defined(VIEWS_IMPLEMENTATION)
+
+#else // defined(WIN32)
+#define VIEWS_EXPORT __attribute__((visibility("default")))
+#endif
+
+#else // defined(COMPONENT_BUILD)
+#define VIEWS_EXPORT
+#endif
+
+#endif // UI_VIEWS_VIEWS_EXPORT_H_
diff --git a/ui/views/widget/default_theme_provider.h b/ui/views/widget/default_theme_provider.h
index a47062e..d0705e2 100644
--- a/ui/views/widget/default_theme_provider.h
+++ b/ui/views/widget/default_theme_provider.h
@@ -11,7 +11,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/base/theme_provider.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
class Profile;
diff --git a/ui/views/widget/monitor_win.h b/ui/views/widget/monitor_win.h
index 627c6ee..4fcbd6f 100644
--- a/ui/views/widget/monitor_win.h
+++ b/ui/views/widget/monitor_win.h
@@ -7,7 +7,8 @@
#pragma once
#include <windows.h>
-#include "views/views_export.h"
+
+#include "ui/views/views_export.h"
namespace gfx {
class Rect;
diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h
index f0fe3ff..a911fec 100644
--- a/ui/views/widget/native_widget_aura.h
+++ b/ui/views/widget/native_widget_aura.h
@@ -11,8 +11,8 @@
#include "ui/aura/client/window_drag_drop_delegate.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/events.h"
+#include "ui/views/views_export.h"
#include "ui/views/widget/native_widget_private.h"
-#include "views/views_export.h"
namespace aura {
class Window;
diff --git a/ui/views/widget/native_widget_delegate.h b/ui/views/widget/native_widget_delegate.h
index 3c33581..317374a 100644
--- a/ui/views/widget/native_widget_delegate.h
+++ b/ui/views/widget/native_widget_delegate.h
@@ -7,7 +7,7 @@
#pragma once
#include "ui/base/events.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Canvas;
diff --git a/ui/views/widget/native_widget_gtk.cc b/ui/views/widget/native_widget_gtk.cc
index 22f1ab4..a970976 100644
--- a/ui/views/widget/native_widget_gtk.cc
+++ b/ui/views/widget/native_widget_gtk.cc
@@ -37,13 +37,13 @@
#include "ui/views/controls/textfield/native_textfield_views.h"
#include "ui/views/focus/view_storage.h"
#include "ui/views/ime/input_method_gtk.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/drop_target_gtk.h"
#include "ui/views/widget/gtk_views_fixed.h"
#include "ui/views/widget/gtk_views_window.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/tooltip_manager_gtk.h"
#include "ui/views/widget/widget_delegate.h"
-#include "views/views_delegate.h"
#if defined(HAVE_IBUS)
#include "ui/views/ime/input_method_ibus.h"
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index 7d0b7c0..5e3ed37 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -38,6 +38,7 @@
#include "ui/views/focus/accelerator_handler.h"
#include "ui/views/focus/view_storage.h"
#include "ui/views/ime/input_method_win.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/aero_tooltip_manager.h"
#include "ui/views/widget/child_window_message_processor.h"
#include "ui/views/widget/drop_target_win.h"
@@ -46,7 +47,6 @@
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/native_frame_view.h"
-#include "views/views_delegate.h"
#pragma comment(lib, "dwmapi.lib")
diff --git a/ui/views/widget/tooltip_manager.h b/ui/views/widget/tooltip_manager.h
index f7d1a8b..63684b6 100644
--- a/ui/views/widget/tooltip_manager.h
+++ b/ui/views/widget/tooltip_manager.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/string16.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Font;
diff --git a/ui/views/widget/tooltip_manager_views.cc b/ui/views/widget/tooltip_manager_views.cc
index 264dbc3..3b2d677 100644
--- a/ui/views/widget/tooltip_manager_views.cc
+++ b/ui/views/widget/tooltip_manager_views.cc
@@ -26,12 +26,12 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/font.h"
#include "ui/gfx/screen.h"
+#include "ui/views/background.h"
+#include "ui/views/border.h"
#include "ui/views/events/event.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/view.h"
#include "ui/views/widget/native_widget.h"
-#include "views/background.h"
-#include "views/border.h"
namespace {
SkColor kTooltipBackground = 0xFF7F7F00;
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 8d8fad7..472e284 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -19,13 +19,13 @@
#include "ui/views/focus/view_storage.h"
#include "ui/views/focus/widget_focus_manager.h"
#include "ui/views/ime/input_method.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/default_theme_provider.h"
#include "ui/views/widget/native_widget_private.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/tooltip_manager.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/custom_frame_view.h"
-#include "views/views_delegate.h"
namespace {
diff --git a/ui/views/widget/widget_delegate.cc b/ui/views/widget/widget_delegate.cc
index 84af2343..6456c61 100644
--- a/ui/views/widget/widget_delegate.cc
+++ b/ui/views/widget/widget_delegate.cc
@@ -8,9 +8,9 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/view.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/client_view.h"
-#include "views/views_delegate.h"
namespace views {
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index 90632c6..81e7515 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -10,8 +10,8 @@
#include "ui/gfx/point.h"
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/test/views_test_base.h"
+#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget_delegate.h"
-#include "views/views_delegate.h"
#if defined(USE_AURA)
#include "ui/aura/window.h"
diff --git a/ui/views/widget/window_manager.h b/ui/views/widget/window_manager.h
index accef0a..abb6232 100644
--- a/ui/views/widget/window_manager.h
+++ b/ui/views/widget/window_manager.h
@@ -8,7 +8,7 @@
#include "base/basictypes.h"
#include "ui/base/events.h"
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Point;
diff --git a/ui/views/window/window_shape.h b/ui/views/window/window_shape.h
index 6db3add..2dfc214 100644
--- a/ui/views/window/window_shape.h
+++ b/ui/views/window/window_shape.h
@@ -6,7 +6,7 @@
#define UI_VIEWS_WINDOW_WINDOW_SHAPE_H_
#pragma once
-#include "views/views_export.h"
+#include "ui/views/views_export.h"
namespace gfx {
class Size;