diff options
author | tyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-07 13:01:04 +0000 |
---|---|---|
committer | tyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-07 13:01:04 +0000 |
commit | 9897cf5715b97b5ad5decd127864de59d9cbf386 (patch) | |
tree | d9024861e8bf463518f0242be8f9fdaf9fb0c117 | |
parent | 9d1f2f21b76737c5c9aadf35b9407bab564eeb8e (diff) | |
download | chromium_src-9897cf5715b97b5ad5decd127864de59d9cbf386.zip chromium_src-9897cf5715b97b5ad5decd127864de59d9cbf386.tar.gz chromium_src-9897cf5715b97b5ad5decd127864de59d9cbf386.tar.bz2 |
Revert 185203
> Fix b175202 -- Cannot paste whitespace characters into Omnibox.
>
> Emit a whitespace if pasted text consists of whitespace.
> Fix gtk Omnibox view implementationomn to use omnibox_view::GetClipboardText.
>
> BUG=175202
>
>
> Review URL: https://chromiumcodereview.appspot.com/12313143
TBR=yhirano@chromium.org
Review URL: https://chromiumcodereview.appspot.com/12593003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186696 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc | 28 | ||||
-rw-r--r-- | chrome/browser/ui/omnibox/omnibox_view.cc | 9 | ||||
-rw-r--r-- | chrome/browser/ui/omnibox/omnibox_view_unittest.cc | 10 |
3 files changed, 16 insertions, 31 deletions
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc index b218033..f2d3eff 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc @@ -1451,22 +1451,22 @@ void OmniboxViewGtk::HandleInsertText(GtkTextBuffer* buffer, if (len == 1 && (text[0] == '\n' || text[0] == '\r')) enter_was_inserted_ = true; - if (model()->is_pasting()) { - filtered_text = GetClipboardText(); - } else { - for (const gchar* p = text; *p && (p - text) < len; - p = g_utf8_next_char(p)) { - gunichar c = g_utf8_get_char(p); - - // 0x200B is Zero Width Space, which is inserted just before the Instant - // anchor for working around the GtkTextView's misalignment bug. - // This character might be captured and inserted into the content by undo - // manager, so we need to filter it out here. - if (c != 0x200B) - base::WriteUnicodeCharacter(c, &filtered_text); - } + for (const gchar* p = text; *p && (p - text) < len; + p = g_utf8_next_char(p)) { + gunichar c = g_utf8_get_char(p); + + // 0x200B is Zero Width Space, which is inserted just before the Instant + // anchor for working around the GtkTextView's misalignment bug. + // This character might be captured and inserted into the content by undo + // manager, so we need to filter it out here. + if (c != 0x200B) + base::WriteUnicodeCharacter(c, &filtered_text); } + if (model()->is_pasting()) + filtered_text = StripJavascriptSchemas( + CollapseWhitespace(filtered_text, true)); + if (!filtered_text.empty()) { // Avoid inserting the text after the Instant anchor. ValidateTextBufferIter(location); diff --git a/chrome/browser/ui/omnibox/omnibox_view.cc b/chrome/browser/ui/omnibox/omnibox_view.cc index 7ff3fbc..f91b981 100644 --- a/chrome/browser/ui/omnibox/omnibox_view.cc +++ b/chrome/browser/ui/omnibox/omnibox_view.cc @@ -38,13 +38,8 @@ string16 OmniboxView::GetClipboardText() { // TODO(shess): It may also make sense to ignore leading or // trailing whitespace when making this determination. for (size_t i = 0; i < text.size(); ++i) { - if (IsWhitespace(text[i]) && text[i] != '\n' && text[i] != '\r') { - const string16 collapsed = CollapseWhitespace(text, false); - // If the user is pasting all-whitespace, paste a single space - // rather than nothing, since pasting nothing feels broken. - return collapsed.empty() ? - ASCIIToUTF16(" ") : StripJavascriptSchemas(collapsed); - } + if (IsWhitespace(text[i]) && text[i] != '\n' && text[i] != '\r') + return StripJavascriptSchemas(CollapseWhitespace(text, false)); } // Otherwise, the only whitespace in |text| is newlines. Remove diff --git a/chrome/browser/ui/omnibox/omnibox_view_unittest.cc b/chrome/browser/ui/omnibox/omnibox_view_unittest.cc index 53bd73d..81c4bb5 100644 --- a/chrome/browser/ui/omnibox/omnibox_view_unittest.cc +++ b/chrome/browser/ui/omnibox/omnibox_view_unittest.cc @@ -58,16 +58,6 @@ TEST_F(OmniboxViewTest, GetClipboardText) { } EXPECT_EQ(kPlainText, OmniboxView::GetClipboardText()); - // Can we pull a string consists of white-space? - const string16 kSpace6(ASCIIToUTF16(" ")); - const string16 kSpace1(ASCIIToUTF16(" ")); - { - ui::ScopedClipboardWriter clipboard_writer(clipboard, - ui::Clipboard::BUFFER_STANDARD); - clipboard_writer.WriteText(kSpace6); - } - EXPECT_EQ(kSpace1, OmniboxView::GetClipboardText()); - // TODO(shess): Aura hits a DCHECK() at CommitToClipboard() if // ObjectMap is empty. http://crbug.com/133848 #if !defined(USE_AURA) |