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_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/logging.h" | 10 #include "base/logging.h" |
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1376 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1376 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
1377 return compositor_.get(); | 1377 return compositor_.get(); |
1378 } | 1378 } |
1379 | 1379 |
1380 void RenderWidget::WillBeginCompositorFrame() { | 1380 void RenderWidget::WillBeginCompositorFrame() { |
1381 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1381 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
1382 | 1382 |
1383 // The following two can result in further layout and possibly | 1383 // The following two can result in further layout and possibly |
1384 // enable GPU acceleration so they need to be called before any painting | 1384 // enable GPU acceleration so they need to be called before any painting |
1385 // is done. | 1385 // is done. |
1386 UpdateTextInputType(); | |
1387 #if defined(OS_ANDROID) | |
1388 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); | 1386 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); |
1389 #endif | |
1390 UpdateSelectionBounds(); | 1387 UpdateSelectionBounds(); |
1391 } | 1388 } |
1392 | 1389 |
1393 void RenderWidget::DidCommitCompositorFrame() { | 1390 void RenderWidget::DidCommitCompositorFrame() { |
1394 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 1391 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
1395 DidCommitCompositorFrame()); | 1392 DidCommitCompositorFrame()); |
1396 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, | 1393 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, |
1397 DidCommitCompositorFrame()); | 1394 DidCommitCompositorFrame()); |
1398 #if defined(VIDEO_HOLE) | 1395 #if defined(VIDEO_HOLE) |
1399 FOR_EACH_OBSERVER(RenderFrameImpl, video_hole_frames_, | 1396 FOR_EACH_OBSERVER(RenderFrameImpl, video_hole_frames_, |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1911 handling_ime_event_ = false; | 1908 handling_ime_event_ = false; |
1912 // While handling an ime event, text input state and selection bounds updates | 1909 // While handling an ime event, text input state and selection bounds updates |
1913 // are ignored. These must explicitly be updated once finished handling the | 1910 // are ignored. These must explicitly be updated once finished handling the |
1914 // ime event. | 1911 // ime event. |
1915 UpdateSelectionBounds(); | 1912 UpdateSelectionBounds(); |
1916 #if defined(OS_ANDROID) | 1913 #if defined(OS_ANDROID) |
1917 UpdateTextInputState(NO_SHOW_IME, FROM_IME); | 1914 UpdateTextInputState(NO_SHOW_IME, FROM_IME); |
1918 #endif | 1915 #endif |
1919 } | 1916 } |
1920 | 1917 |
1921 void RenderWidget::UpdateTextInputType() { | |
1922 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputType"); | |
1923 ui::TextInputType new_type = GetTextInputType(); | |
1924 if (IsDateTimeInput(new_type)) | |
1925 return; // Not considered as a text input field in WebKit/Chromium. | |
1926 | |
1927 bool new_can_compose_inline = CanComposeInline(); | |
1928 | |
1929 blink::WebTextInputInfo new_info; | |
1930 if (webwidget_) | |
1931 new_info = webwidget_->textInputInfo(); | |
1932 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | |
1933 int new_flags = new_info.flags; | |
1934 | |
1935 if (text_input_type_ != new_type | |
1936 || can_compose_inline_ != new_can_compose_inline | |
1937 || text_input_mode_ != new_mode | |
1938 || text_input_flags_ != new_flags) { | |
1939 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), | |
1940 new_type, | |
1941 new_mode, | |
1942 new_can_compose_inline, | |
1943 new_flags)); | |
1944 text_input_type_ = new_type; | |
1945 can_compose_inline_ = new_can_compose_inline; | |
1946 text_input_mode_ = new_mode; | |
1947 text_input_flags_ = new_flags; | |
1948 } | |
1949 } | |
1950 | |
1951 #if defined(OS_ANDROID) || defined(USE_AURA) | |
1952 void RenderWidget::UpdateTextInputState(ShowIme show_ime, | 1918 void RenderWidget::UpdateTextInputState(ShowIme show_ime, |
1953 ChangeSource change_source) { | 1919 ChangeSource change_source) { |
1954 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); | 1920 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); |
1955 if (handling_ime_event_) | 1921 if (handling_ime_event_) |
1956 return; | 1922 return; |
1957 ui::TextInputType new_type = GetTextInputType(); | 1923 ui::TextInputType new_type = GetTextInputType(); |
1958 if (IsDateTimeInput(new_type)) | 1924 if (IsDateTimeInput(new_type)) |
1959 return; // Not considered as a text input field in WebKit/Chromium. | 1925 return; // Not considered as a text input field in WebKit/Chromium. |
1960 | 1926 |
1961 blink::WebTextInputInfo new_info; | 1927 blink::WebTextInputInfo new_info; |
1962 if (webwidget_) | 1928 if (webwidget_) |
1963 new_info = webwidget_->textInputInfo(); | 1929 new_info = webwidget_->textInputInfo(); |
1930 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | |
1964 | 1931 |
1965 bool new_can_compose_inline = CanComposeInline(); | 1932 bool new_can_compose_inline = CanComposeInline(); |
1966 | 1933 |
1967 // Only sends text input params if they are changed or if the ime should be | 1934 // Only sends text input params if they are changed or if the ime should be |
1968 // shown. | 1935 // shown. |
1969 if (show_ime == SHOW_IME_IF_NEEDED || | 1936 if (show_ime == SHOW_IME_IF_NEEDED || |
1970 (text_input_type_ != new_type || | 1937 (text_input_type_ != new_type || |
1938 text_input_mode_ != new_mode || | |
1971 text_input_info_ != new_info || | 1939 text_input_info_ != new_info || |
1972 can_compose_inline_ != new_can_compose_inline) | 1940 can_compose_inline_ != new_can_compose_inline) |
1973 #if defined(OS_ANDROID) | 1941 #if defined(OS_ANDROID) |
1974 || text_field_is_dirty_ | 1942 || text_field_is_dirty_ |
1975 #endif | 1943 #endif |
1976 ) { | 1944 ) { |
1977 ViewHostMsg_TextInputState_Params p; | 1945 ViewHostMsg_TextInputState_Params p; |
nasko
2015/07/29 17:41:08
nit: s/p/params/
Shu Chen
2015/07/30 00:47:22
Done.
| |
1978 p.type = new_type; | 1946 p.type = new_type; |
1947 p.mode = new_mode; | |
1979 p.flags = new_info.flags; | 1948 p.flags = new_info.flags; |
1980 p.value = new_info.value.utf8(); | 1949 p.value = new_info.value.utf8(); |
1981 p.selection_start = new_info.selectionStart; | 1950 p.selection_start = new_info.selectionStart; |
1982 p.selection_end = new_info.selectionEnd; | 1951 p.selection_end = new_info.selectionEnd; |
1983 p.composition_start = new_info.compositionStart; | 1952 p.composition_start = new_info.compositionStart; |
1984 p.composition_end = new_info.compositionEnd; | 1953 p.composition_end = new_info.compositionEnd; |
1985 p.can_compose_inline = new_can_compose_inline; | 1954 p.can_compose_inline = new_can_compose_inline; |
1986 p.show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED); | 1955 p.show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED); |
1987 #if defined(USE_AURA) | 1956 #if defined(USE_AURA) |
1988 p.is_non_ime_change = true; | 1957 p.is_non_ime_change = true; |
1989 #endif | 1958 #endif |
1990 #if defined(OS_ANDROID) | 1959 #if defined(OS_ANDROID) |
1991 p.is_non_ime_change = (change_source == FROM_NON_IME) || | 1960 p.is_non_ime_change = (change_source == FROM_NON_IME) || |
1992 text_field_is_dirty_; | 1961 text_field_is_dirty_; |
1993 if (p.is_non_ime_change) | 1962 if (p.is_non_ime_change) |
1994 IncrementOutstandingImeEventAcks(); | 1963 IncrementOutstandingImeEventAcks(); |
1995 text_field_is_dirty_ = false; | 1964 text_field_is_dirty_ = false; |
1996 #endif | 1965 #endif |
1997 #if defined(USE_AURA) | |
1998 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), | |
1999 new_type, | |
2000 text_input_mode_, | |
2001 new_can_compose_inline, | |
2002 new_info.flags)); | |
2003 #endif | |
2004 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); | 1966 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); |
2005 | 1967 |
2006 text_input_info_ = new_info; | 1968 text_input_info_ = new_info; |
2007 text_input_type_ = new_type; | 1969 text_input_type_ = new_type; |
1970 text_input_mode_ = new_mode; | |
2008 can_compose_inline_ = new_can_compose_inline; | 1971 can_compose_inline_ = new_can_compose_inline; |
2009 text_input_flags_ = new_info.flags; | 1972 text_input_flags_ = new_info.flags; |
2010 } | 1973 } |
2011 } | 1974 } |
2012 #endif | |
2013 | 1975 |
2014 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { | 1976 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { |
2015 WebRect focus_webrect; | 1977 WebRect focus_webrect; |
2016 WebRect anchor_webrect; | 1978 WebRect anchor_webrect; |
2017 webwidget_->selectionBounds(focus_webrect, anchor_webrect); | 1979 webwidget_->selectionBounds(focus_webrect, anchor_webrect); |
2018 *focus = focus_webrect; | 1980 *focus = focus_webrect; |
2019 *anchor = anchor_webrect; | 1981 *anchor = anchor_webrect; |
2020 } | 1982 } |
2021 | 1983 |
2022 void RenderWidget::UpdateSelectionBounds() { | 1984 void RenderWidget::UpdateSelectionBounds() { |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2465 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2427 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2466 video_hole_frames_.AddObserver(frame); | 2428 video_hole_frames_.AddObserver(frame); |
2467 } | 2429 } |
2468 | 2430 |
2469 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2431 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2470 video_hole_frames_.RemoveObserver(frame); | 2432 video_hole_frames_.RemoveObserver(frame); |
2471 } | 2433 } |
2472 #endif // defined(VIDEO_HOLE) | 2434 #endif // defined(VIDEO_HOLE) |
2473 | 2435 |
2474 } // namespace content | 2436 } // namespace content |
OLD | NEW |