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

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

Issue 671503005: Plumb composition character bounds for Android 5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/test/test_render_view_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "ui/gfx/frame_time.h" 70 #include "ui/gfx/frame_time.h"
71 #include "ui/gfx/point_conversions.h" 71 #include "ui/gfx/point_conversions.h"
72 #include "ui/gfx/rect_conversions.h" 72 #include "ui/gfx/rect_conversions.h"
73 #include "ui/gfx/size_conversions.h" 73 #include "ui/gfx/size_conversions.h"
74 #include "ui/gfx/skia_util.h" 74 #include "ui/gfx/skia_util.h"
75 #include "ui/gl/gl_switches.h" 75 #include "ui/gl/gl_switches.h"
76 #include "ui/surface/transport_dib.h" 76 #include "ui/surface/transport_dib.h"
77 77
78 #if defined(OS_ANDROID) 78 #if defined(OS_ANDROID)
79 #include <android/keycodes.h> 79 #include <android/keycodes.h>
80 #include "base/android/build_info.h"
80 #include "content/renderer/android/synchronous_compositor_factory.h" 81 #include "content/renderer/android/synchronous_compositor_factory.h"
81 #endif 82 #endif
82 83
83 #if defined(OS_POSIX) 84 #if defined(OS_POSIX)
84 #include "ipc/ipc_channel_posix.h" 85 #include "ipc/ipc_channel_posix.h"
85 #include "third_party/skia/include/core/SkMallocPixelRef.h" 86 #include "third_party/skia/include/core/SkMallocPixelRef.h"
86 #include "third_party/skia/include/core/SkPixelRef.h" 87 #include "third_party/skia/include/core/SkPixelRef.h"
87 #endif // defined(OS_POSIX) 88 #endif // defined(OS_POSIX)
88 89
89 #include "third_party/WebKit/public/web/WebWidget.h" 90 #include "third_party/WebKit/public/web/WebWidget.h"
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 return; 1535 return;
1535 ImeEventGuard guard(this); 1536 ImeEventGuard guard(this);
1536 if (!webwidget_->setComposition( 1537 if (!webwidget_->setComposition(
1537 text, WebVector<WebCompositionUnderline>(underlines), 1538 text, WebVector<WebCompositionUnderline>(underlines),
1538 selection_start, selection_end)) { 1539 selection_start, selection_end)) {
1539 // If we failed to set the composition text, then we need to let the browser 1540 // If we failed to set the composition text, then we need to let the browser
1540 // process to cancel the input method's ongoing composition session, to make 1541 // process to cancel the input method's ongoing composition session, to make
1541 // sure we are in a consistent state. 1542 // sure we are in a consistent state.
1542 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1543 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1543 } 1544 }
1544 #if defined(OS_MACOSX) || defined(USE_AURA) 1545 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_ANDROID)
1545 UpdateCompositionInfo(true); 1546 UpdateCompositionInfo(true);
aurimas (slooooooooow) 2014/10/22 00:59:04 UpdateCompositionInfo is an expensive call. That w
yukawa 2014/10/22 01:11:35 Not yet, but this is why I added the the version c
1546 #endif 1547 #endif
1547 } 1548 }
1548 1549
1549 void RenderWidget::OnImeConfirmComposition(const base::string16& text, 1550 void RenderWidget::OnImeConfirmComposition(const base::string16& text,
1550 const gfx::Range& replacement_range, 1551 const gfx::Range& replacement_range,
1551 bool keep_selection) { 1552 bool keep_selection) {
1552 if (!ShouldHandleImeEvent()) 1553 if (!ShouldHandleImeEvent())
1553 return; 1554 return;
1554 ImeEventGuard guard(this); 1555 ImeEventGuard guard(this);
1555 handling_input_event_ = true; 1556 handling_input_event_ = true;
1556 if (text.length()) 1557 if (text.length())
1557 webwidget_->confirmComposition(text); 1558 webwidget_->confirmComposition(text);
1558 else if (keep_selection) 1559 else if (keep_selection)
1559 webwidget_->confirmComposition(WebWidget::KeepSelection); 1560 webwidget_->confirmComposition(WebWidget::KeepSelection);
1560 else 1561 else
1561 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); 1562 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection);
1562 handling_input_event_ = false; 1563 handling_input_event_ = false;
1563 #if defined(OS_MACOSX) || defined(USE_AURA) 1564 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_ANDROID)
1564 UpdateCompositionInfo(true); 1565 UpdateCompositionInfo(true);
1565 #endif 1566 #endif
1566 } 1567 }
1567 1568
1568 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { 1569 void RenderWidget::OnRepaint(gfx::Size size_to_paint) {
1569 // During shutdown we can just ignore this message. 1570 // During shutdown we can just ignore this message.
1570 if (!webwidget_) 1571 if (!webwidget_)
1571 return; 1572 return;
1572 1573
1573 // Even if the browser provides an empty damage rect, it's still expecting to 1574 // Even if the browser provides an empty damage rect, it's still expecting to
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 if (selection_anchor_rect_ != params.anchor_rect || 1880 if (selection_anchor_rect_ != params.anchor_rect ||
1880 selection_focus_rect_ != params.focus_rect) { 1881 selection_focus_rect_ != params.focus_rect) {
1881 selection_anchor_rect_ = params.anchor_rect; 1882 selection_anchor_rect_ = params.anchor_rect;
1882 selection_focus_rect_ = params.focus_rect; 1883 selection_focus_rect_ = params.focus_rect;
1883 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir); 1884 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir);
1884 params.is_anchor_first = webwidget_->isSelectionAnchorFirst(); 1885 params.is_anchor_first = webwidget_->isSelectionAnchorFirst();
1885 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); 1886 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params));
1886 } 1887 }
1887 } 1888 }
1888 1889
1889 #if defined(OS_MACOSX) || defined(USE_AURA) 1890 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_ANDROID)
1890 UpdateCompositionInfo(false); 1891 UpdateCompositionInfo(false);
1891 #endif 1892 #endif
1892 } 1893 }
1893 1894
1894 // Check blink::WebTextInputType and ui::TextInputType is kept in sync. 1895 // Check blink::WebTextInputType and ui::TextInputType is kept in sync.
1895 COMPILE_ASSERT(int(blink::WebTextInputTypeNone) == \ 1896 COMPILE_ASSERT(int(blink::WebTextInputTypeNone) == \
1896 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums); 1897 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums);
1897 COMPILE_ASSERT(int(blink::WebTextInputTypeText) == \ 1898 COMPILE_ASSERT(int(blink::WebTextInputTypeText) == \
1898 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums); 1899 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums);
1899 COMPILE_ASSERT(int(blink::WebTextInputTypePassword) == \ 1900 COMPILE_ASSERT(int(blink::WebTextInputTypePassword) == \
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 "blink::WebTextInputType and ui::TextInputType not synchronized"; 1935 "blink::WebTextInputType and ui::TextInputType not synchronized";
1935 return static_cast<ui::TextInputType>(type); 1936 return static_cast<ui::TextInputType>(type);
1936 } 1937 }
1937 1938
1938 ui::TextInputType RenderWidget::GetTextInputType() { 1939 ui::TextInputType RenderWidget::GetTextInputType() {
1939 if (webwidget_) 1940 if (webwidget_)
1940 return WebKitToUiTextInputType(webwidget_->textInputInfo().type); 1941 return WebKitToUiTextInputType(webwidget_->textInputInfo().type);
1941 return ui::TEXT_INPUT_TYPE_NONE; 1942 return ui::TEXT_INPUT_TYPE_NONE;
1942 } 1943 }
1943 1944
1944 #if defined(OS_MACOSX) || defined(USE_AURA) 1945 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_ANDROID)
1945 void RenderWidget::UpdateCompositionInfo(bool should_update_range) { 1946 void RenderWidget::UpdateCompositionInfo(bool should_update_range) {
1947 #if defined(OS_ANDROID)
1948 // Sending composition info makes sense only in Lollipop (API level 21)
1949 // and above due to the API availability.
1950 if (base::android::BuildInfo::GetInstance()->sdk_int() < 21)
1951 return;
1952 #endif
1953
1946 gfx::Range range = gfx::Range(); 1954 gfx::Range range = gfx::Range();
1947 if (should_update_range) { 1955 if (should_update_range) {
1948 GetCompositionRange(&range); 1956 GetCompositionRange(&range);
1949 } else { 1957 } else {
1950 range = composition_range_; 1958 range = composition_range_;
1951 } 1959 }
1952 std::vector<gfx::Rect> character_bounds; 1960 std::vector<gfx::Rect> character_bounds;
1953 GetCompositionCharacterBounds(&character_bounds); 1961 GetCompositionCharacterBounds(&character_bounds);
1954 1962
1955 if (!ShouldUpdateCompositionInfo(range, character_bounds)) 1963 if (!ShouldUpdateCompositionInfo(range, character_bounds))
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 ImeEventGuard guard(this); 2035 ImeEventGuard guard(this);
2028 // If the last text input type is not None, then we should finish any 2036 // If the last text input type is not None, then we should finish any
2029 // ongoing composition regardless of the new text input type. 2037 // ongoing composition regardless of the new text input type.
2030 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { 2038 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
2031 // If a composition text exists, then we need to let the browser process 2039 // If a composition text exists, then we need to let the browser process
2032 // to cancel the input method's ongoing composition session. 2040 // to cancel the input method's ongoing composition session.
2033 if (webwidget_->confirmComposition()) 2041 if (webwidget_->confirmComposition())
2034 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 2042 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
2035 } 2043 }
2036 2044
2037 #if defined(OS_MACOSX) || defined(USE_AURA) 2045 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_ANDROID)
2038 UpdateCompositionInfo(true); 2046 UpdateCompositionInfo(true);
2039 #endif 2047 #endif
2040 } 2048 }
2041 2049
2042 void RenderWidget::didHandleGestureEvent( 2050 void RenderWidget::didHandleGestureEvent(
2043 const WebGestureEvent& event, 2051 const WebGestureEvent& event,
2044 bool event_cancelled) { 2052 bool event_cancelled) {
2045 #if defined(OS_ANDROID) || defined(USE_AURA) 2053 #if defined(OS_ANDROID) || defined(USE_AURA)
2046 if (event_cancelled) 2054 if (event_cancelled)
2047 return; 2055 return;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2247 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2240 video_hole_frames_.AddObserver(frame); 2248 video_hole_frames_.AddObserver(frame);
2241 } 2249 }
2242 2250
2243 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2251 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2244 video_hole_frames_.RemoveObserver(frame); 2252 video_hole_frames_.RemoveObserver(frame);
2245 } 2253 }
2246 #endif // defined(VIDEO_HOLE) 2254 #endif // defined(VIDEO_HOLE)
2247 2255
2248 } // namespace content 2256 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/test/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698