diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 00:07:31 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 00:07:31 +0000 |
commit | d0d639af9da992e49cd9a8fbed43953b9ec0916e (patch) | |
tree | c8837d33539c339d0686c62b2f64dc3fa68b4256 /views/controls/link.cc | |
parent | a337122f70c5681ca03a90067cc2c80423a79a41 (diff) | |
download | chromium_src-d0d639af9da992e49cd9a8fbed43953b9ec0916e.zip chromium_src-d0d639af9da992e49cd9a8fbed43953b9ec0916e.tar.gz chromium_src-d0d639af9da992e49cd9a8fbed43953b9ec0916e.tar.bz2 |
Clean up a few bits of files that I'm about to modify. The only visible change is the removal of some extra spacing Ben erroneously added to the link infobar a while back (clients already do their own spacing as needed, so this just added extra whitespace in mid-sentence).
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/223029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/link.cc')
-rw-r--r-- | views/controls/link.cc | 124 |
1 files changed, 55 insertions, 69 deletions
diff --git a/views/controls/link.cc b/views/controls/link.cc index 34a9e46..c9bd256 100644 --- a/views/controls/link.cc +++ b/views/controls/link.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -61,25 +61,6 @@ const LinkController* Link::GetController() { return controller_; } -std::string Link::GetClassName() const { - return kViewClassName; -} - -void Link::SetHighlightedColor(const SkColor& color) { - normal_color_ = color; - ValidateStyle(); -} - -void Link::SetDisabledColor(const SkColor& color) { - disabled_color_ = color; - ValidateStyle(); -} - -void Link::SetNormalColor(const SkColor& color) { - normal_color_ = color; - ValidateStyle(); -} - bool Link::OnMousePressed(const MouseEvent& e) { if (!enabled_ || (!e.IsLeftMouseButton() && !e.IsMiddleMouseButton())) return false; @@ -117,18 +98,18 @@ bool Link::OnKeyPressed(const KeyEvent& e) { bool activate = false; NOTIMPLEMENTED(); #endif - if (activate) { - SetHighlighted(false); + if (!activate) + return false; - // Focus the link on key pressed. - RequestFocus(); + SetHighlighted(false); - if (controller_) - controller_->LinkActivated(this, e.GetFlags()); + // Focus the link on key pressed. + RequestFocus(); - return true; - } - return false; + if (controller_) + controller_->LinkActivated(this, e.GetFlags()); + + return true; } bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { @@ -141,40 +122,6 @@ bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) { #endif } -void Link::SetHighlighted(bool f) { - if (f != highlighted_) { - highlighted_ = f; - ValidateStyle(); - SchedulePaint(); - } -} - -void Link::ValidateStyle() { - gfx::Font font = GetFont(); - - if (enabled_) { - if ((font.style() & gfx::Font::UNDERLINED) == 0) { - Label::SetFont(font.DeriveFont(0, font.style() | - gfx::Font::UNDERLINED)); - } - } else { - if ((font.style() & gfx::Font::UNDERLINED) != 0) { - Label::SetFont(font.DeriveFont(0, font.style() & - ~gfx::Font::UNDERLINED)); - } - } - - if (enabled_) { - if (highlighted_) { - Label::SetColor(highlighted_color_); - } else { - Label::SetColor(normal_color_); - } - } else { - Label::SetColor(disabled_color_); - } -} - void Link::SetFont(const gfx::Font& font) { Label::SetFont(font); ValidateStyle(); @@ -190,16 +137,55 @@ void Link::SetEnabled(bool f) { gfx::NativeCursor Link::GetCursorForPoint(Event::EventType event_type, int x, int y) { - if (enabled_) { + if (!enabled_) + return NULL; #if defined(OS_WIN) - if (!g_hand_cursor) - g_hand_cursor = LoadCursor(NULL, IDC_HAND); - return g_hand_cursor; + if (!g_hand_cursor) + g_hand_cursor = LoadCursor(NULL, IDC_HAND); + return g_hand_cursor; #elif defined(OS_LINUX) - return gdk_cursor_new(GDK_HAND2); + return gdk_cursor_new(GDK_HAND2); #endif +} + +std::string Link::GetClassName() const { + return kViewClassName; +} + +void Link::SetHighlightedColor(const SkColor& color) { + normal_color_ = color; + ValidateStyle(); +} + +void Link::SetDisabledColor(const SkColor& color) { + disabled_color_ = color; + ValidateStyle(); +} + +void Link::SetNormalColor(const SkColor& color) { + normal_color_ = color; + ValidateStyle(); +} + +void Link::SetHighlighted(bool f) { + if (f != highlighted_) { + highlighted_ = f; + ValidateStyle(); + SchedulePaint(); + } +} + +void Link::ValidateStyle() { + gfx::Font font = GetFont(); + + if (enabled_) { + if ((font.style() & gfx::Font::UNDERLINED) == 0) + Label::SetFont(font.DeriveFont(0, font.style() | gfx::Font::UNDERLINED)); + Label::SetColor(highlighted_ ? highlighted_color_ : normal_color_); } else { - return NULL; + if ((font.style() & gfx::Font::UNDERLINED) != 0) + Label::SetFont(font.DeriveFont(0, font.style() & ~gfx::Font::UNDERLINED)); + Label::SetColor(disabled_color_); } } |