OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_gtk.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #include <gdk/gdkkeysyms.h> | 9 #include <gdk/gdkkeysyms.h> |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 // accidentally DOS the user with a mega tooltip (since GTK doesn't do | 938 // accidentally DOS the user with a mega tooltip (since GTK doesn't do |
939 // this itself). | 939 // this itself). |
940 // I filed https://bugzilla.gnome.org/show_bug.cgi?id=604641 upstream. | 940 // I filed https://bugzilla.gnome.org/show_bug.cgi?id=604641 upstream. |
941 const base::string16 clamped_tooltip = | 941 const base::string16 clamped_tooltip = |
942 gfx::TruncateString(tooltip_text, kMaxTooltipLength); | 942 gfx::TruncateString(tooltip_text, kMaxTooltipLength); |
943 | 943 |
944 if (clamped_tooltip.empty()) { | 944 if (clamped_tooltip.empty()) { |
945 gtk_widget_set_has_tooltip(view_.get(), FALSE); | 945 gtk_widget_set_has_tooltip(view_.get(), FALSE); |
946 } else { | 946 } else { |
947 gtk_widget_set_tooltip_text(view_.get(), | 947 gtk_widget_set_tooltip_text(view_.get(), |
948 UTF16ToUTF8(clamped_tooltip).c_str()); | 948 base::UTF16ToUTF8(clamped_tooltip).c_str()); |
949 } | 949 } |
950 } | 950 } |
951 | 951 |
952 void RenderWidgetHostViewGtk::SelectionChanged(const base::string16& text, | 952 void RenderWidgetHostViewGtk::SelectionChanged(const base::string16& text, |
953 size_t offset, | 953 size_t offset, |
954 const gfx::Range& range) { | 954 const gfx::Range& range) { |
955 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); | 955 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); |
956 | 956 |
957 if (text.empty() || range.is_empty()) | 957 if (text.empty() || range.is_empty()) |
958 return; | 958 return; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 | 1409 |
1410 bool RenderWidgetHostViewGtk::RetrieveSurrounding(std::string* text, | 1410 bool RenderWidgetHostViewGtk::RetrieveSurrounding(std::string* text, |
1411 size_t* cursor_index) { | 1411 size_t* cursor_index) { |
1412 if (!selection_range_.IsValid()) | 1412 if (!selection_range_.IsValid()) |
1413 return false; | 1413 return false; |
1414 | 1414 |
1415 size_t offset = selection_range_.GetMin() - selection_text_offset_; | 1415 size_t offset = selection_range_.GetMin() - selection_text_offset_; |
1416 DCHECK(offset <= selection_text_.length()); | 1416 DCHECK(offset <= selection_text_.length()); |
1417 | 1417 |
1418 if (offset == selection_text_.length()) { | 1418 if (offset == selection_text_.length()) { |
1419 *text = UTF16ToUTF8(selection_text_); | 1419 *text = base::UTF16ToUTF8(selection_text_); |
1420 *cursor_index = text->length(); | 1420 *cursor_index = text->length(); |
1421 return true; | 1421 return true; |
1422 } | 1422 } |
1423 | 1423 |
1424 *text = base::UTF16ToUTF8AndAdjustOffset( | 1424 *text = base::UTF16ToUTF8AndAdjustOffset( |
1425 base::StringPiece16(selection_text_), &offset); | 1425 base::StringPiece16(selection_text_), &offset); |
1426 if (offset == base::string16::npos) { | 1426 if (offset == base::string16::npos) { |
1427 NOTREACHED() << "Invalid offset in UTF16 string."; | 1427 NOTREACHED() << "Invalid offset in UTF16 string."; |
1428 return false; | 1428 return false; |
1429 } | 1429 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 gfx::PluginWindowHandle id) { | 1603 gfx::PluginWindowHandle id) { |
1604 plugin_container_manager_.CreatePluginContainer(id); | 1604 plugin_container_manager_.CreatePluginContainer(id); |
1605 } | 1605 } |
1606 | 1606 |
1607 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( | 1607 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( |
1608 gfx::PluginWindowHandle id) { | 1608 gfx::PluginWindowHandle id) { |
1609 plugin_container_manager_.DestroyPluginContainer(id); | 1609 plugin_container_manager_.DestroyPluginContainer(id); |
1610 } | 1610 } |
1611 | 1611 |
1612 } // namespace content | 1612 } // namespace content |
OLD | NEW |