Index: ui/views/controls/textfield/textfield.cc |
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
index ac2599a3f7ece06e49657789b464bad7d6d6711c..845d604057f98b81115ec294b8251f5513f5b308 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; |
} |
@@ -756,7 +764,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(); |
@@ -837,7 +845,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. |
@@ -849,8 +858,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; |
} |
@@ -1393,8 +1402,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; |
@@ -1474,8 +1483,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 |
@@ -1621,8 +1631,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; |
} |
@@ -1915,8 +1925,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(); |
} |
@@ -2072,7 +2082,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)); |
} |
@@ -2105,9 +2116,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() { |