Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1284)

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2982453002: New AppListView Scroll Behavior. (Closed)
Patch Set: Removed unintended edit. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/controls/textfield/textfield_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 7cb6b9e98c68f7cc4e89c25462ba7d806e30418d..c55ac0097adec442b2fc2c252e6d3a2f4a75cac1 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -398,9 +398,10 @@ SkColor Textfield::GetBackgroundColor() const {
if (!use_default_background_color_)
return background_color_;
- return GetNativeTheme()->GetSystemColor(read_only() || !enabled() ?
- ui::NativeTheme::kColorId_TextfieldReadOnlyBackground :
- ui::NativeTheme::kColorId_TextfieldDefaultBackground);
+ return GetNativeTheme()->GetSystemColor(
+ read_only() || !enabled()
+ ? ui::NativeTheme::kColorId_TextfieldReadOnlyBackground
+ : ui::NativeTheme::kColorId_TextfieldDefaultBackground);
}
void Textfield::SetBackgroundColor(SkColor color) {
@@ -415,10 +416,10 @@ void Textfield::UseDefaultBackgroundColor() {
}
SkColor Textfield::GetSelectionTextColor() const {
- return use_default_selection_text_color_ ?
- GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_TextfieldSelectionColor) :
- selection_text_color_;
+ return use_default_selection_text_color_
+ ? GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_TextfieldSelectionColor)
+ : selection_text_color_;
}
void Textfield::SetSelectionTextColor(SkColor color) {
@@ -435,10 +436,11 @@ void Textfield::UseDefaultSelectionTextColor() {
}
SkColor Textfield::GetSelectionBackgroundColor() const {
- return use_default_selection_background_color_ ?
- GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused) :
- selection_background_color_;
+ return use_default_selection_background_color_
+ ? GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::
+ kColorId_TextfieldSelectionBackgroundFocused)
+ : selection_background_color_;
}
void Textfield::SetSelectionBackgroundColor(SkColor color) {
@@ -582,7 +584,8 @@ int Textfield::GetBaseline() const {
gfx::Size Textfield::CalculatePreferredSize() const {
const gfx::Insets& insets = GetInsets();
return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) +
- insets.width(), GetFontList().GetHeight() + insets.height());
+ insets.width(),
+ GetFontList().GetHeight() + insets.height());
}
const char* Textfield::GetClassName() const {
@@ -619,8 +622,9 @@ bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
#endif
return selection_controller_.OnMousePressed(
- event, handled, had_focus ? SelectionController::FOCUSED
- : SelectionController::UNFOCUSED);
+ event, handled,
+ had_focus ? SelectionController::FOCUSED
+ : SelectionController::UNFOCUSED);
}
bool Textfield::OnMouseDragged(const ui::MouseEvent& event) {
@@ -635,6 +639,10 @@ void Textfield::OnMouseCaptureLost() {
selection_controller_.OnMouseCaptureLost();
}
+bool Textfield::OnMouseWheel(const ui::MouseWheelEvent& event) {
+ return controller_ && controller_->HandleMouseEvent(this, event);
+}
+
WordLookupClient* Textfield::GetWordLookupClient() {
return this;
}
@@ -760,7 +768,7 @@ void Textfield::OnGestureEvent(ui::GestureEvent* event) {
break;
case ui::ET_GESTURE_SCROLL_UPDATE: {
int new_offset = drag_start_display_offset_ + event->location().x() -
- drag_start_location_.x();
+ drag_start_location_.x();
GetRenderText()->SetDisplayOffset(new_offset);
SchedulePaint();
event->SetHandled();
@@ -841,7 +849,8 @@ int Textfield::OnDragUpdated(const ui::DropTargetEvent& event) {
gfx::RenderText* render_text = GetRenderText();
const gfx::Range& selection = render_text->selection();
drop_cursor_position_ = render_text->FindCursorPosition(event.location());
- bool in_selection = !selection.is_empty() &&
+ bool in_selection =
+ !selection.is_empty() &&
selection.Contains(gfx::Range(drop_cursor_position_.caret_pos()));
drop_cursor_visible_ = !in_selection;
// TODO(msw): Pan over text when the user drags to the visible text edge.
@@ -853,8 +862,8 @@ int Textfield::OnDragUpdated(const ui::DropTargetEvent& event) {
if (initiating_drag_) {
if (in_selection)
return ui::DragDropTypes::DRAG_NONE;
- return event.IsControlDown() ? ui::DragDropTypes::DRAG_COPY :
- ui::DragDropTypes::DRAG_MOVE;
+ return event.IsControlDown() ? ui::DragDropTypes::DRAG_COPY
+ : ui::DragDropTypes::DRAG_MOVE;
}
return ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_MOVE;
}
@@ -1398,8 +1407,8 @@ bool Textfield::GetCompositionCharacterBounds(uint32_t index,
return false;
gfx::RenderText* render_text = GetRenderText();
if (!render_text->IsValidCursorIndex(text_index)) {
- text_index = render_text->IndexOfAdjacentGrapheme(
- text_index, gfx::CURSOR_BACKWARD);
+ text_index =
+ render_text->IndexOfAdjacentGrapheme(text_index, gfx::CURSOR_BACKWARD);
}
if (text_index < composition_range.start())
return false;
@@ -1479,8 +1488,9 @@ bool Textfield::ChangeTextDirectionAndLayoutAlignment(
// Restore text directionality mode when the indicated direction matches the
// current forced mode; otherwise, force the mode indicated. This helps users
// manage BiDi text layout without getting stuck in forced LTR or RTL modes.
- const gfx::DirectionalityMode mode = direction == base::i18n::RIGHT_TO_LEFT ?
- gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR;
+ const gfx::DirectionalityMode mode = direction == base::i18n::RIGHT_TO_LEFT
+ ? gfx::DIRECTIONALITY_FORCE_RTL
+ : gfx::DIRECTIONALITY_FORCE_LTR;
if (mode == GetRenderText()->directionality_mode())
GetRenderText()->SetDirectionalityMode(gfx::DIRECTIONALITY_FROM_TEXT);
else
@@ -1626,8 +1636,8 @@ gfx::Point Textfield::GetLastClickLocation() const {
base::string16 Textfield::GetSelectionClipboardText() const {
base::string16 selection_clipboard_text;
- ui::Clipboard::GetForCurrentThread()->ReadText(
- ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text);
+ ui::Clipboard::GetForCurrentThread()->ReadText(ui::CLIPBOARD_TYPE_SELECTION,
+ &selection_clipboard_text);
return selection_clipboard_text;
}
@@ -1920,8 +1930,8 @@ void Textfield::UpdateBackgroundColor() {
// Disable subpixel rendering when the background color is transparent
// because it draws incorrect colors around the glyphs in that case.
// See crbug.com/115198
- GetRenderText()->set_subpixel_rendering_suppressed(
- SkColorGetA(color) != SK_AlphaOPAQUE);
+ GetRenderText()->set_subpixel_rendering_suppressed(SkColorGetA(color) !=
+ SK_AlphaOPAQUE);
SchedulePaint();
}
@@ -2077,7 +2087,8 @@ void Textfield::RevealPasswordChar(int index) {
SchedulePaint();
if (index != -1) {
- password_reveal_timer_.Start(FROM_HERE, GetPasswordRevealDuration(),
+ password_reveal_timer_.Start(
+ FROM_HERE, GetPasswordRevealDuration(),
base::Bind(&Textfield::RevealPasswordChar,
weak_ptr_factory_.GetWeakPtr(), -1));
}
@@ -2110,9 +2121,10 @@ bool Textfield::ShouldBlinkCursor() const {
void Textfield::StartBlinkingCursor() {
DCHECK(ShouldBlinkCursor());
- cursor_blink_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(
- Textfield::GetCaretBlinkMs()),
- this, &Textfield::OnCursorBlinkTimerFired);
+ cursor_blink_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(Textfield::GetCaretBlinkMs()), this,
+ &Textfield::OnCursorBlinkTimerFired);
}
void Textfield::StopBlinkingCursor() {
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/controls/textfield/textfield_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698