OLD | NEW |
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 "chrome/browser/renderer_host/render_widget_host_view_views.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 745 |
746 gfx::Rect RenderWidgetHostViewViews::GetCaretBounds() { | 746 gfx::Rect RenderWidgetHostViewViews::GetCaretBounds() { |
747 return selection_start_rect_.Union(selection_end_rect_); | 747 return selection_start_rect_.Union(selection_end_rect_); |
748 } | 748 } |
749 | 749 |
750 bool RenderWidgetHostViewViews::HasCompositionText() { | 750 bool RenderWidgetHostViewViews::HasCompositionText() { |
751 return has_composition_text_; | 751 return has_composition_text_; |
752 } | 752 } |
753 | 753 |
754 bool RenderWidgetHostViewViews::GetTextRange(ui::Range* range) { | 754 bool RenderWidgetHostViewViews::GetTextRange(ui::Range* range) { |
755 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 755 *range = ui::Range(selection_text_offset_, |
756 NOTIMPLEMENTED(); | 756 selection_text_offset_ + selection_text_.length()); |
757 return false; | 757 return true; |
758 } | 758 } |
759 | 759 |
760 bool RenderWidgetHostViewViews::GetCompositionTextRange(ui::Range* range) { | 760 bool RenderWidgetHostViewViews::GetCompositionTextRange(ui::Range* range) { |
761 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 761 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
762 NOTIMPLEMENTED(); | 762 NOTIMPLEMENTED(); |
763 return false; | 763 return false; |
764 } | 764 } |
765 | 765 |
766 bool RenderWidgetHostViewViews::GetSelectionRange(ui::Range* range) { | 766 bool RenderWidgetHostViewViews::GetSelectionRange(ui::Range* range) { |
767 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 767 *range = selection_range_; |
768 NOTIMPLEMENTED(); | 768 return true; |
769 return false; | |
770 } | 769 } |
771 | 770 |
772 bool RenderWidgetHostViewViews::SetSelectionRange(const ui::Range& range) { | 771 bool RenderWidgetHostViewViews::SetSelectionRange(const ui::Range& range) { |
773 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 772 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
774 NOTIMPLEMENTED(); | 773 NOTIMPLEMENTED(); |
775 return false; | 774 return false; |
776 } | 775 } |
777 | 776 |
778 bool RenderWidgetHostViewViews::DeleteRange(const ui::Range& range) { | 777 bool RenderWidgetHostViewViews::DeleteRange(const ui::Range& range) { |
779 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 778 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
780 NOTIMPLEMENTED(); | 779 NOTIMPLEMENTED(); |
781 return false; | 780 return false; |
782 } | 781 } |
783 | 782 |
784 bool RenderWidgetHostViewViews::GetTextFromRange( | 783 bool RenderWidgetHostViewViews::GetTextFromRange( |
785 const ui::Range& range, | 784 const ui::Range& range, |
786 const base::Callback<void(const string16&)>& callback) { | 785 string16* text, |
787 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 786 ui::Range* actual_range) { |
788 NOTIMPLEMENTED(); | 787 ui::Range selection_text_range( |
789 return false; | 788 selection_text_offset_, |
| 789 selection_text_offset_ + selection_text_.length()); |
| 790 *actual_range = selection_text_range.Intersect(range); |
| 791 |
| 792 if (!actual_range->IsValid() || actual_range->is_empty()) { |
| 793 text->clear(); |
| 794 } else { |
| 795 *text = selection_text_.substr( |
| 796 actual_range->GetMin() - selection_text_offset_, |
| 797 actual_range->length()); |
| 798 } |
| 799 |
| 800 return true; |
790 } | 801 } |
791 | 802 |
792 void RenderWidgetHostViewViews::OnInputMethodChanged() { | 803 void RenderWidgetHostViewViews::OnInputMethodChanged() { |
793 if (!host_) | 804 if (!host_) |
794 return; | 805 return; |
795 | 806 |
796 DCHECK(GetInputMethod()); | 807 DCHECK(GetInputMethod()); |
797 host_->SetInputMethodActive(GetInputMethod()->IsActive()); | 808 host_->SetInputMethodActive(GetInputMethod()->IsActive()); |
798 | 809 |
799 // TODO(suzhe): implement the newly added “locale” property of HTML DOM | 810 // TODO(suzhe): implement the newly added “locale” property of HTML DOM |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 for (std::vector< base::Callback<void(void)> >::const_iterator | 1170 for (std::vector< base::Callback<void(void)> >::const_iterator |
1160 it = on_compositing_ended_callbacks_.begin(); | 1171 it = on_compositing_ended_callbacks_.begin(); |
1161 it != on_compositing_ended_callbacks_.end(); ++it) { | 1172 it != on_compositing_ended_callbacks_.end(); ++it) { |
1162 it->Run(); | 1173 it->Run(); |
1163 } | 1174 } |
1164 on_compositing_ended_callbacks_.clear(); | 1175 on_compositing_ended_callbacks_.clear(); |
1165 compositor->RemoveObserver(this); | 1176 compositor->RemoveObserver(this); |
1166 } | 1177 } |
1167 | 1178 |
1168 #endif | 1179 #endif |
OLD | NEW |