Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: ui/views/controls/scroll_view.cc

Issue 2716793004: Revert of Change focus indicator for TableView and TreeView. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/scroll_view.h ('k') | ui/views/controls/table/table_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/scroll_view.cc
diff --git a/ui/views/controls/scroll_view.cc b/ui/views/controls/scroll_view.cc
index d58f8478857fee42f0b5e3a51b8a948b665f3195..f457cb7c67ccec7191db74cd14b80f495055e4cb 100644
--- a/ui/views/controls/scroll_view.cc
+++ b/ui/views/controls/scroll_view.cc
@@ -7,7 +7,6 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "ui/base/material_design/material_design_controller.h"
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
#include "ui/native_theme/native_theme.h"
@@ -32,7 +31,23 @@
#endif
};
-class ScrollCornerView : public View {
+// Subclass of ScrollView that resets the border when the theme changes.
+class ScrollViewWithBorder : public views::ScrollView {
+ public:
+ ScrollViewWithBorder() {}
+
+ // View overrides;
+ void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
+ SetBorder(CreateSolidBorder(
+ 1,
+ theme->GetSystemColor(ui::NativeTheme::kColorId_UnfocusedBorderColor)));
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScrollViewWithBorder);
+};
+
+class ScrollCornerView : public views::View {
public:
ScrollCornerView() {}
@@ -181,21 +196,7 @@
// static
ScrollView* ScrollView::CreateScrollViewWithBorder() {
- auto scroll_view = new ScrollView();
- scroll_view->AddBorder();
- return scroll_view;
-}
-
-// static
-ScrollView* ScrollView::GetScrollViewForContents(View* contents) {
- View* grandparent =
- contents->parent() ? contents->parent()->parent() : nullptr;
- if (!grandparent || grandparent->GetClassName() != ScrollView::kViewClassName)
- return nullptr;
-
- auto scroll_view = static_cast<ScrollView*>(grandparent);
- DCHECK_EQ(contents, scroll_view->contents());
- return scroll_view;
+ return new ScrollViewWithBorder();
}
void ScrollView::SetContents(View* a_view) {
@@ -268,21 +269,14 @@
vert_sb_ = vert_sb;
}
-void ScrollView::SetHasFocusIndicator(bool has_focus_indicator) {
- if (has_focus_indicator == draw_focus_indicator_)
- return;
- draw_focus_indicator_ = has_focus_indicator;
-
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
- DCHECK_EQ(draw_focus_indicator_, !focus_ring_);
- if (has_focus_indicator) {
- focus_ring_ = FocusRing::Install(this);
- } else {
- FocusRing::Uninstall(this);
- focus_ring_ = nullptr;
- }
+void ScrollView::SetHasFocusRing(bool has_focus_ring) {
+ if (has_focus_ring == (focus_ring_ != nullptr))
+ return;
+ if (has_focus_ring) {
+ focus_ring_ = FocusRing::Install(this);
} else {
- UpdateBorder();
+ FocusRing::Uninstall(this);
+ focus_ring_ = nullptr;
}
SchedulePaint();
}
@@ -521,10 +515,6 @@
const char* ScrollView::GetClassName() const {
return kViewClassName;
-}
-
-void ScrollView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
- UpdateBorder();
}
void ScrollView::ScrollToPosition(ScrollBar* source, int position) {
@@ -744,23 +734,6 @@
header_->SetX(-x_offset);
header_->SchedulePaintInRect(header_->GetVisibleBounds());
}
-}
-
-void ScrollView::AddBorder() {
- draw_border_ = true;
- UpdateBorder();
-}
-
-void ScrollView::UpdateBorder() {
- if (!draw_border_ || !GetWidget())
- return;
-
- SetBorder(CreateSolidBorder(
- 1,
- GetNativeTheme()->GetSystemColor(
- draw_focus_indicator_
- ? ui::NativeTheme::kColorId_FocusedBorderColor
- : ui::NativeTheme::kColorId_UnfocusedBorderColor)));
}
// VariableRowHeightScrollHelper ----------------------------------------------
« no previous file with comments | « ui/views/controls/scroll_view.h ('k') | ui/views/controls/table/table_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698