| Index: ui/views/controls/link.cc
|
| ===================================================================
|
| --- ui/views/controls/link.cc (revision 239550)
|
| +++ ui/views/controls/link.cc (working copy)
|
| @@ -43,11 +43,6 @@
|
| #endif
|
| }
|
|
|
| -void Link::OnEnabledChanged() {
|
| - RecalculateFont();
|
| - View::OnEnabledChanged();
|
| -}
|
| -
|
| const char* Link::GetClassName() const {
|
| return kViewClassName;
|
| }
|
| @@ -63,25 +58,6 @@
|
| #endif
|
| }
|
|
|
| -void Link::OnPaint(gfx::Canvas* canvas) {
|
| - Label::OnPaint(canvas);
|
| -
|
| - if (HasFocus())
|
| - canvas->DrawFocusRect(GetLocalBounds());
|
| -}
|
| -
|
| -void Link::OnFocus() {
|
| - Label::OnFocus();
|
| - // We render differently focused.
|
| - SchedulePaint();
|
| -}
|
| -
|
| -void Link::OnBlur() {
|
| - Label::OnBlur();
|
| - // We render differently focused.
|
| - SchedulePaint();
|
| -}
|
| -
|
| bool Link::HitTestRect(const gfx::Rect& rect) const {
|
| // We need to allow clicks on the link. So we override the implementation in
|
| // Label and use the default implementation of View.
|
| @@ -139,17 +115,6 @@
|
| return true;
|
| }
|
|
|
| -bool Link::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
|
| - // Make sure we don't process space or enter as accelerators.
|
| - return (event.key_code() == ui::VKEY_SPACE) ||
|
| - (event.key_code() == ui::VKEY_RETURN);
|
| -}
|
| -
|
| -void Link::GetAccessibleState(ui::AccessibleViewState* state) {
|
| - Label::GetAccessibleState(state);
|
| - state->role = ui::AccessibilityTypes::ROLE_LINK;
|
| -}
|
| -
|
| void Link::OnGestureEvent(ui::GestureEvent* event) {
|
| if (!enabled())
|
| return;
|
| @@ -167,11 +132,54 @@
|
| event->SetHandled();
|
| }
|
|
|
| +bool Link::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) {
|
| + // Make sure we don't process space or enter as accelerators.
|
| + return (event.key_code() == ui::VKEY_SPACE) ||
|
| + (event.key_code() == ui::VKEY_RETURN);
|
| +}
|
| +
|
| +void Link::GetAccessibleState(ui::AccessibleViewState* state) {
|
| + Label::GetAccessibleState(state);
|
| + state->role = ui::AccessibilityTypes::ROLE_LINK;
|
| +}
|
| +
|
| +void Link::OnEnabledChanged() {
|
| + RecalculateFont();
|
| + View::OnEnabledChanged();
|
| +}
|
| +
|
| +void Link::OnPaint(gfx::Canvas* canvas) {
|
| + Label::OnPaint(canvas);
|
| +
|
| + if (HasFocus())
|
| + canvas->DrawFocusRect(GetLocalBounds());
|
| +}
|
| +
|
| +void Link::OnFocus() {
|
| + Label::OnFocus();
|
| + // We render differently focused.
|
| + SchedulePaint();
|
| +}
|
| +
|
| +void Link::OnBlur() {
|
| + Label::OnBlur();
|
| + // We render differently focused.
|
| + SchedulePaint();
|
| +}
|
| +
|
| void Link::SetFont(const gfx::Font& font) {
|
| Label::SetFont(font);
|
| RecalculateFont();
|
| }
|
|
|
| +void Link::SetText(const string16& text) {
|
| + Label::SetText(text);
|
| + // Disable focusability for empty links. Otherwise Label::GetInsets() will
|
| + // give them an unconditional 1-px. inset on every side to allow for a focus
|
| + // border, when in this case we probably wanted zero width.
|
| + set_focusable(!text.empty());
|
| +}
|
| +
|
| void Link::SetEnabledColor(SkColor color) {
|
| requested_enabled_color_ = color;
|
| if (!pressed_)
|
| @@ -205,7 +213,12 @@
|
| SetPressedColor(SK_ColorRED);
|
| #endif
|
| RecalculateFont();
|
| - set_focusable(true);
|
| +
|
| + // Label::Init() calls SetText(), but if that's being called from Label(), our
|
| + // SetText() override will not be reached (because the constructed class is
|
| + // only a Label at the moment, not yet a Link). So so the set_focusable()
|
| + // call explicitly here.
|
| + set_focusable(!text().empty());
|
| }
|
|
|
| void Link::SetPressed(bool pressed) {
|
|
|