Commit 684dae9c authored by msw@chromium.org's avatar msw@chromium.org

Deprecate unused views::Label::SetURL().

Reasons to deprecate:
1) This function is unused in production.
2) The directionality code was wrong:
2a: Used Unicode control character wrapping.
2b: DCHECKing URL validity precludes invalid schemes with RTL leading substrings anyway.
3) The only tangible benefit (calling ui::ElideURL) is minimal.
4) It's easy to restore (or re-impl better) if needed.

BUG=NONE
TEST=NONE

Review URL: https://chromiumcodereview.appspot.com/10829047

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148806 0039d316-1c4b-4281-b951-d872f2087c98
parent e8c136e5
...@@ -55,7 +55,6 @@ void Label::SetFont(const gfx::Font& font) { ...@@ -55,7 +55,6 @@ void Label::SetFont(const gfx::Font& font) {
void Label::SetText(const string16& text) { void Label::SetText(const string16& text) {
text_ = text; text_ = text;
url_ = GURL();
text_size_valid_ = false; text_size_valid_ = false;
is_email_ = false; is_email_ = false;
PreferredSizeChanged(); PreferredSizeChanged();
...@@ -67,16 +66,6 @@ void Label::SetEmail(const string16& email) { ...@@ -67,16 +66,6 @@ void Label::SetEmail(const string16& email) {
is_email_ = true; is_email_ = true;
} }
void Label::SetURL(const GURL& url) {
DCHECK(url.is_valid());
url_ = url;
text_ = UTF8ToUTF16(url_.spec());
text_size_valid_ = false;
is_email_ = false;
PreferredSizeChanged();
SchedulePaint();
}
void Label::SetAutoColorReadabilityEnabled(bool enabled) { void Label::SetAutoColorReadabilityEnabled(bool enabled) {
auto_color_readability_ = enabled; auto_color_readability_ = enabled;
RecalculateColors(); RecalculateColors();
...@@ -494,24 +483,7 @@ void Label::CalculateDrawStringParams(string16* paint_text, ...@@ -494,24 +483,7 @@ void Label::CalculateDrawStringParams(string16* paint_text,
int* flags) const { int* flags) const {
DCHECK(paint_text && text_bounds && flags); DCHECK(paint_text && text_bounds && flags);
if (!url_.is_empty()) { if (is_email_) {
// TODO(jungshik) : Figure out how to get 'intl.accept_languages'
// preference and use it when calling ElideUrl.
*paint_text =
ui::ElideUrl(url_, font_, GetAvailableRect().width(), std::string());
// An URLs is always treated as an LTR text and therefore we should
// explicitly mark it as such if the locale is RTL so that URLs containing
// Hebrew or Arabic characters are displayed correctly.
//
// Note that we don't check the View's UI layout setting in order to
// determine whether or not to insert the special Unicode formatting
// characters. We use the locale settings because an URL is always treated
// as an LTR string, even if its containing view does not use an RTL UI
// layout.
*paint_text = base::i18n::GetDisplayStringInLTRDirectionality(
*paint_text);
} else if (is_email_) {
*paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width()); *paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width());
} else if (elide_in_middle_) { } else if (elide_in_middle_) {
*paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(), *paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(),
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/string16.h" #include "base/string16.h"
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/font.h" #include "ui/gfx/font.h"
#include "ui/views/view.h" #include "ui/views/view.h"
...@@ -65,9 +64,6 @@ class VIEWS_EXPORT Label : public View { ...@@ -65,9 +64,6 @@ class VIEWS_EXPORT Label : public View {
// Sets the label text to |email|. Emails have a custom eliding algorithm. // Sets the label text to |email|. Emails have a custom eliding algorithm.
void SetEmail(const string16& email); void SetEmail(const string16& email);
// Sets URL Value - text_ is set to spec().
void SetURL(const GURL& url);
// Returns the font used by this label. // Returns the font used by this label.
gfx::Font font() const { return font_; } gfx::Font font() const { return font_; }
...@@ -258,7 +254,6 @@ class VIEWS_EXPORT Label : public View { ...@@ -258,7 +254,6 @@ class VIEWS_EXPORT Label : public View {
int* flags) const; int* flags) const;
string16 text_; string16 text_;
GURL url_;
gfx::Font font_; gfx::Font font_;
SkColor requested_enabled_color_; SkColor requested_enabled_color_;
SkColor actual_enabled_color_; SkColor actual_enabled_color_;
......
...@@ -47,14 +47,6 @@ TEST(LabelTest, TextProperty) { ...@@ -47,14 +47,6 @@ TEST(LabelTest, TextProperty) {
EXPECT_EQ(test_text, label.text()); EXPECT_EQ(test_text, label.text());
} }
TEST(LabelTest, UrlProperty) {
Label label;
std::string my_url("http://www.orkut.com/some/Random/path");
GURL url(my_url);
label.SetURL(url);
EXPECT_EQ(UTF8ToUTF16(my_url), label.text());
}
TEST(LabelTest, ColorProperty) { TEST(LabelTest, ColorProperty) {
Label label; Label label;
SkColor color = SkColorSetARGB(20, 40, 10, 5); SkColor color = SkColorSetARGB(20, 40, 10, 5);
......
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