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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 // Clamp the tooltip length to kMaxTooltipLength so that we don't | 377 // Clamp the tooltip length to kMaxTooltipLength so that we don't |
378 // accidentally DOS the user with a mega tooltip. | 378 // accidentally DOS the user with a mega tooltip. |
379 tooltip_text_ = ui::TruncateString(tip, kMaxTooltipLength); | 379 tooltip_text_ = ui::TruncateString(tip, kMaxTooltipLength); |
380 if (GetWidget()) | 380 if (GetWidget()) |
381 GetWidget()->TooltipTextChanged(this); | 381 GetWidget()->TooltipTextChanged(this); |
382 } | 382 } |
383 | 383 |
384 void RenderWidgetHostViewViews::SelectionChanged(const string16& text, | 384 void RenderWidgetHostViewViews::SelectionChanged(const string16& text, |
385 size_t offset, | 385 size_t offset, |
386 const ui::Range& range) { | 386 const ui::Range& range) { |
387 selection_text_ = text; | 387 RenderWidgetHostView::SelectionChanged(text, offset, range); |
388 selection_text_offset_ = offset; | |
389 selection_range_ = range; | |
390 | |
391 // TODO(anicolao): deal with the clipboard without GTK | 388 // TODO(anicolao): deal with the clipboard without GTK |
392 NOTIMPLEMENTED(); | 389 NOTIMPLEMENTED(); |
393 } | 390 } |
394 | 391 |
395 void RenderWidgetHostViewViews::SelectionBoundsChanged( | 392 void RenderWidgetHostViewViews::SelectionBoundsChanged( |
396 const gfx::Rect& start_rect, | 393 const gfx::Rect& start_rect, |
397 const gfx::Rect& end_rect) { | 394 const gfx::Rect& end_rect) { |
398 views::InputMethod* input_method = GetInputMethod(); | 395 views::InputMethod* input_method = GetInputMethod(); |
399 | 396 |
400 if (selection_start_rect_ == start_rect && selection_end_rect_ == end_rect) | 397 if (selection_start_rect_ == start_rect && selection_end_rect_ == end_rect) |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 742 |
746 gfx::Rect RenderWidgetHostViewViews::GetCaretBounds() { | 743 gfx::Rect RenderWidgetHostViewViews::GetCaretBounds() { |
747 return selection_start_rect_.Union(selection_end_rect_); | 744 return selection_start_rect_.Union(selection_end_rect_); |
748 } | 745 } |
749 | 746 |
750 bool RenderWidgetHostViewViews::HasCompositionText() { | 747 bool RenderWidgetHostViewViews::HasCompositionText() { |
751 return has_composition_text_; | 748 return has_composition_text_; |
752 } | 749 } |
753 | 750 |
754 bool RenderWidgetHostViewViews::GetTextRange(ui::Range* range) { | 751 bool RenderWidgetHostViewViews::GetTextRange(ui::Range* range) { |
755 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 752 *range = ui::Range(selection_text_offset_, |
756 NOTIMPLEMENTED(); | 753 selection_text_offset_ + selection_text_.length()); |
757 return false; | 754 return true; |
758 } | 755 } |
759 | 756 |
760 bool RenderWidgetHostViewViews::GetCompositionTextRange(ui::Range* range) { | 757 bool RenderWidgetHostViewViews::GetCompositionTextRange(ui::Range* range) { |
761 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 758 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
762 NOTIMPLEMENTED(); | 759 NOTIMPLEMENTED(); |
763 return false; | 760 return false; |
764 } | 761 } |
765 | 762 |
766 bool RenderWidgetHostViewViews::GetSelectionRange(ui::Range* range) { | 763 bool RenderWidgetHostViewViews::GetSelectionRange(ui::Range* range) { |
767 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 764 *range = selection_range_; |
768 NOTIMPLEMENTED(); | 765 return true; |
769 return false; | |
770 } | 766 } |
771 | 767 |
772 bool RenderWidgetHostViewViews::SetSelectionRange(const ui::Range& range) { | 768 bool RenderWidgetHostViewViews::SetSelectionRange(const ui::Range& range) { |
773 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 769 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
774 NOTIMPLEMENTED(); | 770 NOTIMPLEMENTED(); |
775 return false; | 771 return false; |
776 } | 772 } |
777 | 773 |
778 bool RenderWidgetHostViewViews::DeleteRange(const ui::Range& range) { | 774 bool RenderWidgetHostViewViews::DeleteRange(const ui::Range& range) { |
779 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 775 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. |
780 NOTIMPLEMENTED(); | 776 NOTIMPLEMENTED(); |
781 return false; | 777 return false; |
782 } | 778 } |
783 | 779 |
784 bool RenderWidgetHostViewViews::GetTextFromRange( | 780 bool RenderWidgetHostViewViews::GetTextFromRange( |
785 const ui::Range& range, | 781 const ui::Range& range, |
786 const base::Callback<void(const string16&)>& callback) { | 782 string16* text, |
787 // TODO(suzhe): implement this method when fixing http://crbug.com/55130. | 783 ui::Range* actual_range) { |
788 NOTIMPLEMENTED(); | 784 ui::Range selection_text_range( |
789 return false; | 785 selection_text_offset_, |
| 786 selection_text_offset_ + selection_text_.length()); |
| 787 *actual_range = selection_text_range.Intersect(range); |
| 788 |
| 789 if (!actual_range->IsValid() || actual_range->is_empty()) { |
| 790 text->clear(); |
| 791 } else { |
| 792 *text = selection_text_.substr( |
| 793 actual_range->GetMin() - selection_text_offset_, |
| 794 actual_range->length()); |
| 795 } |
| 796 |
| 797 return true; |
790 } | 798 } |
791 | 799 |
792 void RenderWidgetHostViewViews::OnInputMethodChanged() { | 800 void RenderWidgetHostViewViews::OnInputMethodChanged() { |
793 if (!host_) | 801 if (!host_) |
794 return; | 802 return; |
795 | 803 |
796 DCHECK(GetInputMethod()); | 804 DCHECK(GetInputMethod()); |
797 host_->SetInputMethodActive(GetInputMethod()->IsActive()); | 805 host_->SetInputMethodActive(GetInputMethod()->IsActive()); |
798 | 806 |
799 // TODO(suzhe): implement the newly added “locale” property of HTML DOM | 807 // 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 | 1167 for (std::vector< base::Callback<void(void)> >::const_iterator |
1160 it = on_compositing_ended_callbacks_.begin(); | 1168 it = on_compositing_ended_callbacks_.begin(); |
1161 it != on_compositing_ended_callbacks_.end(); ++it) { | 1169 it != on_compositing_ended_callbacks_.end(); ++it) { |
1162 it->Run(); | 1170 it->Run(); |
1163 } | 1171 } |
1164 on_compositing_ended_callbacks_.clear(); | 1172 on_compositing_ended_callbacks_.clear(); |
1165 compositor->RemoveObserver(this); | 1173 compositor->RemoveObserver(this); |
1166 } | 1174 } |
1167 | 1175 |
1168 #endif | 1176 #endif |
OLD | NEW |