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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 2012823003: Move IME related functions from WebFrame to WebLocalFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add CHECK in TextInputController::HasMarkedText() Created 4 years, 5 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
OLDNEW
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 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 } 1654 }
1655 1655
1656 void RenderViewImpl::didCancelCompositionOnSelectionChange() { 1656 void RenderViewImpl::didCancelCompositionOnSelectionChange() {
1657 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); 1657 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID()));
1658 } 1658 }
1659 1659
1660 bool RenderViewImpl::handleCurrentKeyboardEvent() { 1660 bool RenderViewImpl::handleCurrentKeyboardEvent() {
1661 if (edit_commands_.empty()) 1661 if (edit_commands_.empty())
1662 return false; 1662 return false;
1663 1663
1664 WebFrame* frame = webview()->focusedFrame(); 1664 WebLocalFrame* frame = webview()->focusedFrame();
1665 if (!frame)
1666 return false;
1667 1665
1668 EditCommands::iterator it = edit_commands_.begin(); 1666 EditCommands::iterator it = edit_commands_.begin();
1669 EditCommands::iterator end = edit_commands_.end(); 1667 EditCommands::iterator end = edit_commands_.end();
1670 1668
1671 bool did_execute_command = false; 1669 bool did_execute_command = false;
1672 for (; it != end; ++it) { 1670 for (; it != end; ++it) {
1673 // In gtk and cocoa, it's possible to bind multiple edit commands to one 1671 // In gtk and cocoa, it's possible to bind multiple edit commands to one
1674 // key (but it's the exception). Once one edit command is not executed, it 1672 // key (but it's the exception). Once one edit command is not executed, it
1675 // seems safest to not execute the rest. 1673 // seems safest to not execute the rest.
1676 if (!frame->executeCommand(WebString::fromUTF8(it->name), 1674 if (!frame->executeCommand(WebString::fromUTF8(it->name),
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); 2742 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin();
2745 if (focused_pepper_plugin) { 2743 if (focused_pepper_plugin) {
2746 focused_pepper_plugin->render_frame()->OnImeSetComposition( 2744 focused_pepper_plugin->render_frame()->OnImeSetComposition(
2747 text, underlines, selection_start, selection_end); 2745 text, underlines, selection_start, selection_end);
2748 return; 2746 return;
2749 } 2747 }
2750 #endif // ENABLE_PLUGINS 2748 #endif // ENABLE_PLUGINS
2751 if (replacement_range.IsValid() && webview()) { 2749 if (replacement_range.IsValid() && webview()) {
2752 // Select the text in |replacement_range|, it will then be replaced by 2750 // Select the text in |replacement_range|, it will then be replaced by
2753 // text added by the call to RenderWidget::OnImeSetComposition(). 2751 // text added by the call to RenderWidget::OnImeSetComposition().
2754 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { 2752 WebLocalFrame* frame = webview()->focusedFrame();
2755 WebRange webrange = WebRange::fromDocumentRange( 2753 WebRange webrange = WebRange::fromDocumentRange(
2756 frame, replacement_range.start(), replacement_range.length()); 2754 frame, replacement_range.start(), replacement_range.length());
2757 if (!webrange.isNull()) 2755 if (!webrange.isNull())
2758 frame->selectRange(webrange); 2756 frame->selectRange(webrange);
2759 }
2760 } 2757 }
2761 RenderWidget::OnImeSetComposition(text, 2758 RenderWidget::OnImeSetComposition(text,
2762 underlines, 2759 underlines,
2763 replacement_range, 2760 replacement_range,
2764 selection_start, 2761 selection_start,
2765 selection_end); 2762 selection_end);
2766 } 2763 }
2767 2764
2768 void RenderViewImpl::OnImeConfirmComposition( 2765 void RenderViewImpl::OnImeConfirmComposition(
2769 const base::string16& text, 2766 const base::string16& text,
2770 const gfx::Range& replacement_range, 2767 const gfx::Range& replacement_range,
2771 bool keep_selection) { 2768 bool keep_selection) {
2772 #if defined(ENABLE_PLUGINS) 2769 #if defined(ENABLE_PLUGINS)
2773 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin(); 2770 PepperPluginInstanceImpl* focused_pepper_plugin = GetFocusedPepperPlugin();
2774 if (focused_pepper_plugin) { 2771 if (focused_pepper_plugin) {
2775 focused_pepper_plugin->render_frame()->OnImeConfirmComposition( 2772 focused_pepper_plugin->render_frame()->OnImeConfirmComposition(
2776 text, replacement_range, keep_selection); 2773 text, replacement_range, keep_selection);
2777 return; 2774 return;
2778 } 2775 }
2779 #endif // ENABLE_PLUGINS 2776 #endif // ENABLE_PLUGINS
2780 if (replacement_range.IsValid() && webview()) { 2777 if (replacement_range.IsValid() && webview()) {
2781 // Select the text in |replacement_range|, it will then be replaced by 2778 // Select the text in |replacement_range|, it will then be replaced by
2782 // text added by the call to RenderWidget::OnImeConfirmComposition(). 2779 // text added by the call to RenderWidget::OnImeConfirmComposition().
2783 if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { 2780 WebLocalFrame* frame = webview()->focusedFrame();
2784 WebRange webrange = WebRange::fromDocumentRange( 2781 WebRange webrange = WebRange::fromDocumentRange(
2785 frame, replacement_range.start(), replacement_range.length()); 2782 frame, replacement_range.start(), replacement_range.length());
2786 if (!webrange.isNull()) 2783 if (!webrange.isNull())
2787 frame->selectRange(webrange); 2784 frame->selectRange(webrange);
2788 }
2789 } 2785 }
2790 RenderWidget::OnImeConfirmComposition(text, 2786 RenderWidget::OnImeConfirmComposition(text,
2791 replacement_range, 2787 replacement_range,
2792 keep_selection); 2788 keep_selection);
2793 } 2789 }
2794 2790
2795 void RenderViewImpl::RenderWidgetDidSetColorProfile( 2791 void RenderViewImpl::RenderWidgetDidSetColorProfile(
2796 const std::vector<char>& profile) { 2792 const std::vector<char>& profile) {
2797 if (webview()) { 2793 if (webview()) {
2798 bool was_reset = (profile.size() == 1 && profile[0] == '0'); 2794 bool was_reset = (profile.size() == 1 && profile[0] == '0');
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 2842
2847 if (!webview()) 2843 if (!webview())
2848 return; 2844 return;
2849 size_t start_offset = 0; 2845 size_t start_offset = 0;
2850 size_t character_count = 0; 2846 size_t character_count = 0;
2851 if (!webview()->compositionRange(&start_offset, &character_count)) 2847 if (!webview()->compositionRange(&start_offset, &character_count))
2852 return; 2848 return;
2853 if (character_count == 0) 2849 if (character_count == 0)
2854 return; 2850 return;
2855 2851
2856 blink::WebFrame* frame = webview()->focusedFrame(); 2852 blink::WebLocalFrame* frame = webview()->focusedFrame();
2857 if (!frame)
2858 return;
2859 2853
2860 bounds_in_window->reserve(character_count); 2854 bounds_in_window->reserve(character_count);
2861 blink::WebRect webrect; 2855 blink::WebRect webrect;
2862 for (size_t i = 0; i < character_count; ++i) { 2856 for (size_t i = 0; i < character_count; ++i) {
2863 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { 2857 if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) {
2864 DLOG(ERROR) << "Could not retrieve character rectangle at " << i; 2858 DLOG(ERROR) << "Could not retrieve character rectangle at " << i;
2865 bounds_in_window->clear(); 2859 bounds_in_window->clear();
2866 return; 2860 return;
2867 } 2861 }
2868 ConvertViewportToWindowViaWidget(&webrect); 2862 ConvertViewportToWindowViaWidget(&webrect);
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
3255 return render_frame->focused_pepper_plugin(); 3249 return render_frame->focused_pepper_plugin();
3256 } 3250 }
3257 frame = frame->traverseNext(false); 3251 frame = frame->traverseNext(false);
3258 } 3252 }
3259 3253
3260 return nullptr; 3254 return nullptr;
3261 } 3255 }
3262 #endif 3256 #endif
3263 3257
3264 } // namespace content 3258 } // namespace content
OLDNEW
« no previous file with comments | « components/test_runner/text_input_controller.cc ('k') | content/renderer/text_input_client_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698