Commit e645161b authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Use Button::SetState, not View::SetEnabled, in PaymentRequestRowView

When not clickable, the PaymentRequestRowView needs to disable its
Button behavior but still allow its children to receive events.
View::SetEnabled(false) will disable both. This changes it to just set
the Button state instead.

Fixed: 1068872
Change-Id: I3ee43a6f4fd9d9c48578ba4f5c7b90e67243897f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142147Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757591}
parent 7920b6e8
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
namespace payments { namespace payments {
// static
constexpr char PaymentRequestRowView::kClassName[];
PaymentRequestRowView::PaymentRequestRowView(views::ButtonListener* listener, PaymentRequestRowView::PaymentRequestRowView(views::ButtonListener* listener,
bool clickable, bool clickable,
const gfx::Insets& insets) const gfx::Insets& insets)
...@@ -20,13 +23,21 @@ PaymentRequestRowView::PaymentRequestRowView(views::ButtonListener* listener, ...@@ -20,13 +23,21 @@ PaymentRequestRowView::PaymentRequestRowView(views::ButtonListener* listener,
clickable_(clickable), clickable_(clickable),
insets_(insets), insets_(insets),
previous_row_(nullptr) { previous_row_(nullptr) {
SetEnabled(clickable_); // When not clickable, use Button's STATE_DISABLED but don't set our
// View state to disabled. The former ensures we aren't clickable, the
// latter also disables us and our children for event handling.
views::Button::SetState(clickable_ ? views::Button::STATE_NORMAL
: views::Button::STATE_DISABLED);
ShowBottomSeparator(); ShowBottomSeparator();
SetFocusBehavior(views::View::FocusBehavior::ALWAYS); SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
} }
PaymentRequestRowView::~PaymentRequestRowView() {} PaymentRequestRowView::~PaymentRequestRowView() {}
const char* PaymentRequestRowView::GetClassName() const {
return kClassName;
}
void PaymentRequestRowView::SetActiveBackground() { void PaymentRequestRowView::SetActiveBackground() {
// TODO(crbug/976890): Check whether we can GetSystemColor from a NativeTheme // TODO(crbug/976890): Check whether we can GetSystemColor from a NativeTheme
// ColorId instead of hard code here. // ColorId instead of hard code here.
......
...@@ -17,6 +17,8 @@ class PaymentRequestRowView ...@@ -17,6 +17,8 @@ class PaymentRequestRowView
: public views::Button, : public views::Button,
public base::SupportsWeakPtr<PaymentRequestRowView> { public base::SupportsWeakPtr<PaymentRequestRowView> {
public: public:
static constexpr char kClassName[] = "PaymentRequestRowView";
// Creates a row view. If |clickable| is true, the row will be shaded on hover // Creates a row view. If |clickable| is true, the row will be shaded on hover
// and handle click events. |insets| are used as padding around the content. // and handle click events. |insets| are used as padding around the content.
PaymentRequestRowView(views::ButtonListener* listener, PaymentRequestRowView(views::ButtonListener* listener,
...@@ -28,6 +30,9 @@ class PaymentRequestRowView ...@@ -28,6 +30,9 @@ class PaymentRequestRowView
previous_row_ = previous_row; previous_row_ = previous_row;
} }
// views::View:
const char* GetClassName() const override;
protected: protected:
bool clickable() { return clickable_; } bool clickable() { return clickable_; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment