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

Side by Side Diff: views/controls/textfield/native_textfield_views.cc

Issue 7458014: Implement Uniscribe RenderText for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Seek parity with RenderTextLinux, nix tentative word breaking, address comments. Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/controls/textfield/native_textfield_views.h" 5 #include "views/controls/textfield/native_textfield_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return text_cursor ? gfx::GetCursor(GDK_XTERM) : NULL; 292 return text_cursor ? gfx::GetCursor(GDK_XTERM) : NULL;
293 #endif 293 #endif
294 } 294 }
295 295
296 ///////////////////////////////////////////////////////////////// 296 /////////////////////////////////////////////////////////////////
297 // NativeTextfieldViews, ContextMenuController overrides: 297 // NativeTextfieldViews, ContextMenuController overrides:
298 void NativeTextfieldViews::ShowContextMenuForView(View* source, 298 void NativeTextfieldViews::ShowContextMenuForView(View* source,
299 const gfx::Point& p, 299 const gfx::Point& p,
300 bool is_mouse_gesture) { 300 bool is_mouse_gesture) {
301 UpdateContextMenu(); 301 UpdateContextMenu();
302 if (context_menu_runner_->RunMenuAt( 302 if (context_menu_runner_->RunMenuAt(
xji 2011/08/26 17:59:26 which bug does this address?
msw 2011/08/26 20:10:43 The change you see here between patchsets is not p
xji 2011/08/26 20:36:44 got it. thanks for the explanation!
303 GetWidget(), NULL, gfx::Rect(p, gfx::Size()), 303 GetWidget(), NULL, gfx::Rect(p, gfx::Size()),
304 views::MenuItemView::TOPLEFT, MenuRunner::HAS_MNEMONICS) == 304 views::MenuItemView::TOPLEFT, MenuRunner::HAS_MNEMONICS) ==
305 MenuRunner::MENU_DELETED) 305 MenuRunner::MENU_DELETED)
306 return; 306 return;
307 } 307 }
308 308
309 ///////////////////////////////////////////////////////////////// 309 /////////////////////////////////////////////////////////////////
310 // NativeTextfieldViews, views::DragController overrides: 310 // NativeTextfieldViews, views::DragController overrides:
311 void NativeTextfieldViews::WriteDragDataForView(views::View* sender, 311 void NativeTextfieldViews::WriteDragDataForView(views::View* sender,
312 const gfx::Point& press_pt, 312 const gfx::Point& press_pt,
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 model_->MoveCursorRight( 867 model_->MoveCursorRight(
868 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, selection); 868 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, selection);
869 cursor_changed = true; 869 cursor_changed = true;
870 break; 870 break;
871 case ui::VKEY_LEFT: 871 case ui::VKEY_LEFT:
872 model_->MoveCursorLeft( 872 model_->MoveCursorLeft(
873 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, selection); 873 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, selection);
874 cursor_changed = true; 874 cursor_changed = true;
875 break; 875 break;
876 case ui::VKEY_END: 876 case ui::VKEY_END:
877 model_->MoveCursorRight(gfx::LINE_BREAK, selection);
878 cursor_changed = true;
879 break;
880 case ui::VKEY_HOME: 877 case ui::VKEY_HOME:
881 model_->MoveCursorLeft(gfx::LINE_BREAK, selection); 878 if ((key_code == ui::VKEY_HOME) ==
879 (GetRenderText()->GetTextDirection() == base::i18n::RIGHT_TO_LEFT))
xji 2011/08/26 17:59:26 thanks!
msw 2011/08/26 20:10:43 :)
880 model_->MoveCursorRight(gfx::LINE_BREAK, selection);
881 else
882 model_->MoveCursorLeft(gfx::LINE_BREAK, selection);
882 cursor_changed = true; 883 cursor_changed = true;
883 break; 884 break;
884 case ui::VKEY_BACK: 885 case ui::VKEY_BACK:
885 if (!editable) 886 if (!editable)
886 break; 887 break;
887 if (!model_->HasSelection()) { 888 if (!model_->HasSelection()) {
888 if (selection && control) { 889 if (selection && control) {
889 // If both shift and control are pressed, then erase upto the 890 // If both shift and control are pressed, then erase upto the
890 // beginning of the buffer in ChromeOS. In windows, do nothing. 891 // beginning of the buffer in ChromeOS. In windows, do nothing.
891 #if defined(OS_WIN) 892 #if defined(OS_WIN)
(...skipping 22 matching lines...) Expand all
914 model_->MoveCursorRight(gfx::LINE_BREAK, true); 915 model_->MoveCursorRight(gfx::LINE_BREAK, true);
915 #endif 916 #endif
916 } else if (control) { 917 } else if (control) {
917 // If only control is pressed, then erase the next word. 918 // If only control is pressed, then erase the next word.
918 model_->MoveCursorRight(gfx::WORD_BREAK, true); 919 model_->MoveCursorRight(gfx::WORD_BREAK, true);
919 } 920 }
920 } 921 }
921 cursor_changed = text_changed = model_->Delete(); 922 cursor_changed = text_changed = model_->Delete();
922 break; 923 break;
923 case ui::VKEY_INSERT: 924 case ui::VKEY_INSERT:
924 GetRenderText()->toggle_insert_mode(); 925 GetRenderText()->ToggleInsertMode();
925 cursor_changed = true; 926 cursor_changed = true;
926 break; 927 break;
927 default: 928 default:
928 break; 929 break;
929 } 930 }
930 931
931 // We must have input method in order to support text input. 932 // We must have input method in order to support text input.
932 DCHECK(textfield_->GetInputMethod()); 933 DCHECK(textfield_->GetInputMethod());
933 934
934 UpdateAfterChange(text_changed, cursor_changed); 935 UpdateAfterChange(text_changed, cursor_changed);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 // Notify selection controller 998 // Notify selection controller
998 if (!touch_selection_controller_.get()) 999 if (!touch_selection_controller_.get())
999 return; 1000 return;
1000 gfx::RenderText* render_text = GetRenderText(); 1001 gfx::RenderText* render_text = GetRenderText();
1001 const gfx::SelectionModel& sel = render_text->selection_model(); 1002 const gfx::SelectionModel& sel = render_text->selection_model();
1002 gfx::SelectionModel start_sel(sel.selection_start(), sel.selection_start(), 1003 gfx::SelectionModel start_sel(sel.selection_start(), sel.selection_start(),
1003 sel.selection_start(), gfx::SelectionModel::LEADING); 1004 sel.selection_start(), gfx::SelectionModel::LEADING);
1004 gfx::Rect start_cursor = render_text->GetCursorBounds(start_sel, false); 1005 gfx::Rect start_cursor = render_text->GetCursorBounds(start_sel, false);
1005 gfx::Rect end_cursor = render_text->GetCursorBounds(sel, false); 1006 gfx::Rect end_cursor = render_text->GetCursorBounds(sel, false);
1006 gfx::Point start(start_cursor.x(), start_cursor.bottom() - 1); 1007 gfx::Point start(start_cursor.x(), start_cursor.bottom() - 1);
1007 gfx::Point end(end_cursor.x(), end_cursor.bottom() - 1); 1008 gfx::Point end(end_cursor.x(), end_cursor.bottom() - 1);
xji 2011/08/26 17:59:26 is it the right change for touch ui's selection ha
msw 2011/08/26 20:10:43 See above, what you're seeing isn't part of my cha
1008 touch_selection_controller_->SelectionChanged(start, end); 1009 touch_selection_controller_->SelectionChanged(start, end);
1009 } 1010 }
1010 1011
1011 void NativeTextfieldViews::OnBeforeUserAction() { 1012 void NativeTextfieldViews::OnBeforeUserAction() {
1012 TextfieldController* controller = textfield_->GetController(); 1013 TextfieldController* controller = textfield_->GetController();
1013 if (controller) 1014 if (controller)
1014 controller->OnBeforeUserAction(textfield_); 1015 controller->OnBeforeUserAction(textfield_);
1015 } 1016 }
1016 1017
1017 void NativeTextfieldViews::OnAfterUserAction() { 1018 void NativeTextfieldViews::OnAfterUserAction() {
(...skipping 20 matching lines...) Expand all
1038 // Filter out all control characters, including tab and new line characters, 1039 // Filter out all control characters, including tab and new line characters,
1039 // and all characters with Alt modifier. But we need to allow characters with 1040 // and all characters with Alt modifier. But we need to allow characters with
1040 // AltGr modifier. 1041 // AltGr modifier.
1041 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different 1042 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different
1042 // flag that we don't care about. 1043 // flag that we don't care about.
1043 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && 1044 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
1044 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; 1045 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN;
1045 } 1046 }
1046 1047
1047 } // namespace views 1048 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698