| 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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 } | 1647 } |
| 1648 | 1648 |
| 1649 void RenderViewImpl::didCancelCompositionOnSelectionChange() { | 1649 void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
| 1650 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); | 1650 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 bool RenderViewImpl::handleCurrentKeyboardEvent() { | 1653 bool RenderViewImpl::handleCurrentKeyboardEvent() { |
| 1654 if (edit_commands_.empty()) | 1654 if (edit_commands_.empty()) |
| 1655 return false; | 1655 return false; |
| 1656 | 1656 |
| 1657 WebFrame* frame = webview()->focusedFrame(); | 1657 WebLocalFrame* frame = webview()->focusedFrame(); |
| 1658 if (!frame) | |
| 1659 return false; | |
| 1660 | 1658 |
| 1661 EditCommands::iterator it = edit_commands_.begin(); | 1659 EditCommands::iterator it = edit_commands_.begin(); |
| 1662 EditCommands::iterator end = edit_commands_.end(); | 1660 EditCommands::iterator end = edit_commands_.end(); |
| 1663 | 1661 |
| 1664 bool did_execute_command = false; | 1662 bool did_execute_command = false; |
| 1665 for (; it != end; ++it) { | 1663 for (; it != end; ++it) { |
| 1666 // In gtk and cocoa, it's possible to bind multiple edit commands to one | 1664 // In gtk and cocoa, it's possible to bind multiple edit commands to one |
| 1667 // key (but it's the exception). Once one edit command is not executed, it | 1665 // key (but it's the exception). Once one edit command is not executed, it |
| 1668 // seems safest to not execute the rest. | 1666 // seems safest to not execute the rest. |
| 1669 if (!frame->executeCommand(WebString::fromUTF8(it->name), | 1667 if (!frame->executeCommand(WebString::fromUTF8(it->name), |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2738 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); | 2736 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); |
| 2739 if (focused_pepper_plugin) { | 2737 if (focused_pepper_plugin) { |
| 2740 focused_pepper_plugin->render_frame()->OnImeSetComposition( | 2738 focused_pepper_plugin->render_frame()->OnImeSetComposition( |
| 2741 text, underlines, selection_start, selection_end); | 2739 text, underlines, selection_start, selection_end); |
| 2742 return; | 2740 return; |
| 2743 } | 2741 } |
| 2744 #endif // ENABLE_PLUGINS | 2742 #endif // ENABLE_PLUGINS |
| 2745 if (replacement_range.IsValid() && webview()) { | 2743 if (replacement_range.IsValid() && webview()) { |
| 2746 // Select the text in |replacement_range|, it will then be replaced by | 2744 // Select the text in |replacement_range|, it will then be replaced by |
| 2747 // text added by the call to RenderWidget::OnImeSetComposition(). | 2745 // text added by the call to RenderWidget::OnImeSetComposition(). |
| 2748 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { | 2746 WebLocalFrame* frame = webview()->focusedFrame(); |
| 2749 WebRange webrange = WebRange::fromDocumentRange( | 2747 WebRange webrange = WebRange::fromDocumentRange( |
| 2750 frame, replacement_range.start(), replacement_range.length()); | 2748 frame, replacement_range.start(), replacement_range.length()); |
| 2751 if (!webrange.isNull()) | 2749 if (!webrange.isNull()) |
| 2752 frame->selectRange(webrange); | 2750 frame->selectRange(webrange); |
| 2753 } | |
| 2754 } | 2751 } |
| 2755 RenderWidget::OnImeSetComposition(text, | 2752 RenderWidget::OnImeSetComposition(text, |
| 2756 underlines, | 2753 underlines, |
| 2757 replacement_range, | 2754 replacement_range, |
| 2758 selection_start, | 2755 selection_start, |
| 2759 selection_end); | 2756 selection_end); |
| 2760 } | 2757 } |
| 2761 | 2758 |
| 2762 void RenderViewImpl::OnImeConfirmComposition( | 2759 void RenderViewImpl::OnImeConfirmComposition( |
| 2763 const base::string16& text, | 2760 const base::string16& text, |
| 2764 const gfx::Range& replacement_range, | 2761 const gfx::Range& replacement_range, |
| 2765 bool keep_selection) { | 2762 bool keep_selection) { |
| 2766 #if defined(ENABLE_PLUGINS) | 2763 #if defined(ENABLE_PLUGINS) |
| 2767 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); | 2764 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); |
| 2768 if (focused_pepper_plugin) { | 2765 if (focused_pepper_plugin) { |
| 2769 focused_pepper_plugin->render_frame()->OnImeConfirmComposition( | 2766 focused_pepper_plugin->render_frame()->OnImeConfirmComposition( |
| 2770 text, replacement_range, keep_selection); | 2767 text, replacement_range, keep_selection); |
| 2771 return; | 2768 return; |
| 2772 } | 2769 } |
| 2773 #endif // ENABLE_PLUGINS | 2770 #endif // ENABLE_PLUGINS |
| 2774 if (replacement_range.IsValid() && webview()) { | 2771 if (replacement_range.IsValid() && webview()) { |
| 2775 // Select the text in |replacement_range|, it will then be replaced by | 2772 // Select the text in |replacement_range|, it will then be replaced by |
| 2776 // text added by the call to RenderWidget::OnImeConfirmComposition(). | 2773 // text added by the call to RenderWidget::OnImeConfirmComposition(). |
| 2777 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { | 2774 WebLocalFrame* frame = webview()->focusedFrame(); |
| 2778 WebRange webrange = WebRange::fromDocumentRange( | 2775 WebRange webrange = WebRange::fromDocumentRange( |
| 2779 frame, replacement_range.start(), replacement_range.length()); | 2776 frame, replacement_range.start(), replacement_range.length()); |
| 2780 if (!webrange.isNull()) | 2777 if (!webrange.isNull()) |
| 2781 frame->selectRange(webrange); | 2778 frame->selectRange(webrange); |
| 2782 } | |
| 2783 } | 2779 } |
| 2784 RenderWidget::OnImeConfirmComposition(text, | 2780 RenderWidget::OnImeConfirmComposition(text, |
| 2785 replacement_range, | 2781 replacement_range, |
| 2786 keep_selection); | 2782 keep_selection); |
| 2787 } | 2783 } |
| 2788 | 2784 |
| 2789 void RenderViewImpl::RenderWidgetDidSetColorProfile( | 2785 void RenderViewImpl::RenderWidgetDidSetColorProfile( |
| 2790 const std::vector<char>& profile) { | 2786 const std::vector<char>& profile) { |
| 2791 if (webview()) { | 2787 if (webview()) { |
| 2792 bool was_reset = (profile.size() == 1 && profile[0] == '0'); | 2788 bool was_reset = (profile.size() == 1 && profile[0] == '0'); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2840 | 2836 |
| 2841 if (!webview()) | 2837 if (!webview()) |
| 2842 return; | 2838 return; |
| 2843 size_t start_offset = 0; | 2839 size_t start_offset = 0; |
| 2844 size_t character_count = 0; | 2840 size_t character_count = 0; |
| 2845 if (!webview()->compositionRange(&start_offset, &character_count)) | 2841 if (!webview()->compositionRange(&start_offset, &character_count)) |
| 2846 return; | 2842 return; |
| 2847 if (character_count == 0) | 2843 if (character_count == 0) |
| 2848 return; | 2844 return; |
| 2849 | 2845 |
| 2850 blink::WebFrame* frame = webview()->focusedFrame(); | 2846 blink::WebLocalFrame* frame = webview()->focusedFrame(); |
| 2851 if (!frame) | |
| 2852 return; | |
| 2853 | 2847 |
| 2854 bounds_in_window->reserve(character_count); | 2848 bounds_in_window->reserve(character_count); |
| 2855 blink::WebRect webrect; | 2849 blink::WebRect webrect; |
| 2856 for (size_t i = 0; i < character_count; ++i) { | 2850 for (size_t i = 0; i < character_count; ++i) { |
| 2857 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { | 2851 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { |
| 2858 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; | 2852 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; |
| 2859 bounds_in_window->clear(); | 2853 bounds_in_window->clear(); |
| 2860 return; | 2854 return; |
| 2861 } | 2855 } |
| 2862 ConvertViewportToWindowViaWidget(&webrect); | 2856 ConvertViewportToWindowViaWidget(&webrect); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3262 return render_frame->focused_pepper_plugin(); | 3256 return render_frame->focused_pepper_plugin(); |
| 3263 } | 3257 } |
| 3264 frame = frame->traverseNext(false); | 3258 frame = frame->traverseNext(false); |
| 3265 } | 3259 } |
| 3266 | 3260 |
| 3267 return nullptr; | 3261 return nullptr; |
| 3268 } | 3262 } |
| 3269 #endif | 3263 #endif |
| 3270 | 3264 |
| 3271 } // namespace content | 3265 } // namespace content |
| OLD | NEW |