Commit 51d7d8c9 authored by Jeffrey's avatar Jeffrey Committed by Commit Bot

Ignore whitespace input in fakebox when focused

This change fixes the bug from the omnibox side. When the fakebox is
focused, the omnibox will be in an "invisible focus" state. So these
changes prevent the focus state to change if whitespace is inputted or
pasted into the fakebox. The existing behaviour for dragging whitespace
text into the fakebox does not hide the fakebox. That was not changed.

A small change was made to the fakebox cursor, so when the fakebox is
hidden, hovering over that area shows the default cursor instead of the
text cursor.

R=ramyan@chromium.org, treib@chromium.org

Bug: 727302
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Id075e3e52113d5e8e27e2e1bab74926a6b8bc723
Reviewed-on: https://chromium-review.googlesource.com/1127488
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575188}
parent a36acfde
......@@ -110,7 +110,7 @@ button {
}
body.hide-fakebox #fakebox {
opacity: 0;
visibility: hidden;
}
#logo {
......
......@@ -437,16 +437,24 @@ base::string16 OmniboxViewViews::GetSelectedText() const {
void OmniboxViewViews::OnPaste() {
const base::string16 text(GetClipboardText());
if (!text.empty()) {
OnBeforePossibleChange();
// Record this paste, so we can do different behavior.
model()->OnPaste();
// Force a Paste operation to trigger the text_changed code in
// OnAfterPossibleChange(), even if identical contents are pasted.
state_before_change_.text.clear();
InsertOrReplaceText(text);
OnAfterPossibleChange(true);
if (text.empty() ||
// When the fakebox is focused, ignore pasted whitespace because if the
// fakebox is hidden and there's only whitespace in the omnibox, it's
// difficult for the user to see that the focus moved to the omnibox.
(model()->focus_state() == OMNIBOX_FOCUS_INVISIBLE &&
std::all_of(text.begin(), text.end(), base::IsUnicodeWhitespace))) {
return;
}
OnBeforePossibleChange();
// Record this paste, so we can do different behavior.
model()->OnPaste();
// Force a Paste operation to trigger the text_changed code in
// OnAfterPossibleChange(), even if identical contents are pasted.
state_before_change_.text.clear();
InsertOrReplaceText(text);
OnAfterPossibleChange(true);
}
bool OmniboxViewViews::HandleEarlyTabActions(const ui::KeyEvent& event) {
......@@ -1095,6 +1103,14 @@ base::string16 OmniboxViewViews::GetSelectionClipboardText() const {
}
void OmniboxViewViews::DoInsertChar(base::char16 ch) {
// When the fakebox is focused, ignore whitespace input because if the
// fakebox is hidden and there's only whitespace in the omnibox, it's
// difficult for the user to see that the focus moved to the omnibox.
if ((model()->focus_state() == OMNIBOX_FOCUS_INVISIBLE) &&
base::IsUnicodeWhitespace(ch)) {
return;
}
// If |insert_char_time_| is not null, there's a pending insert char operation
// that hasn't been painted yet. Keep the earlier time.
if (insert_char_time_.is_null()) {
......
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