Chromium Code Reviews| 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_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 | 436 |
| 437 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( | 437 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( |
| 438 RenderWidgetHostImpl* widget_host, | 438 RenderWidgetHostImpl* widget_host, |
| 439 ContentViewCoreImpl* content_view_core) | 439 ContentViewCoreImpl* content_view_core) |
| 440 : host_(widget_host), | 440 : host_(widget_host), |
| 441 begin_frame_source_(nullptr), | 441 begin_frame_source_(nullptr), |
| 442 outstanding_begin_frame_requests_(0), | 442 outstanding_begin_frame_requests_(0), |
| 443 is_showing_(!widget_host->is_hidden()), | 443 is_showing_(!widget_host->is_hidden()), |
| 444 is_window_visible_(true), | 444 is_window_visible_(true), |
| 445 is_window_activity_started_(true), | 445 is_window_activity_started_(true), |
| 446 is_showing_overscroll_glow_(true), | 446 is_in_vr_(false), |
| 447 content_view_core_(nullptr), | 447 content_view_core_(nullptr), |
| 448 ime_adapter_android_(this), | 448 ime_adapter_android_(this), |
| 449 cached_background_color_(SK_ColorWHITE), | 449 cached_background_color_(SK_ColorWHITE), |
| 450 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), | 450 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), |
| 451 gesture_provider_(ui::GetGestureProviderConfig( | 451 gesture_provider_(ui::GetGestureProviderConfig( |
| 452 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 452 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
| 453 this), | 453 this), |
| 454 stylus_text_selector_(this), | 454 stylus_text_selector_(this), |
| 455 using_browser_compositor_(CompositorImpl::IsInitialized()), | 455 using_browser_compositor_(CompositorImpl::IsInitialized()), |
| 456 synchronous_compositor_client_(nullptr), | 456 synchronous_compositor_client_(nullptr), |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 RenderWidgetHostViewBase* updated_view, | 769 RenderWidgetHostViewBase* updated_view, |
| 770 bool did_change_state) { | 770 bool did_change_state) { |
| 771 DCHECK_EQ(text_input_manager_, text_input_manager); | 771 DCHECK_EQ(text_input_manager_, text_input_manager); |
| 772 // If there are no active widgets, the TextInputState.type should be reported | 772 // If there are no active widgets, the TextInputState.type should be reported |
| 773 // as none. | 773 // as none. |
| 774 const TextInputState& state = | 774 const TextInputState& state = |
| 775 GetTextInputManager()->GetActiveWidget() | 775 GetTextInputManager()->GetActiveWidget() |
| 776 ? *GetTextInputManager()->GetTextInputState() | 776 ? *GetTextInputManager()->GetTextInputState() |
| 777 : TextInputState(); | 777 : TextInputState(); |
| 778 | 778 |
| 779 if (!content_view_core_) | 779 if (!content_view_core_ || is_in_vr_) |
|
EhsanK
2017/01/13 21:55:24
I was wondering if the intention of the CL was to
asimjour
2017/01/16 19:28:41
This is a temporary solution. For now I want to st
EhsanK
2017/01/16 20:23:11
sgtm. The benefit of doing (2) is not sending unus
| |
| 780 return; | 780 return; |
| 781 | 781 |
| 782 content_view_core_->UpdateImeAdapter( | 782 content_view_core_->UpdateImeAdapter( |
|
EhsanK
2017/01/13 21:55:24
Regarding the second point above: Here I think the
asimjour
2017/01/16 19:28:41
The UpdateImeAdapter is doing more, but other chan
EhsanK
2017/01/16 20:23:11
Acknowledged.
| |
| 783 GetNativeImeAdapter(), static_cast<int>(state.type), state.flags, | 783 GetNativeImeAdapter(), static_cast<int>(state.type), state.flags, |
| 784 state.mode, state.value, state.selection_start, state.selection_end, | 784 state.mode, state.value, state.selection_start, state.selection_end, |
| 785 state.composition_start, state.composition_end, state.show_ime_if_needed, | 785 state.composition_start, state.composition_end, state.show_ime_if_needed, |
| 786 state.is_non_ime_change); | 786 state.is_non_ime_change); |
| 787 } | 787 } |
| 788 | 788 |
| 789 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) { | 789 void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) { |
| 790 if (cached_background_color_ == color) | 790 if (cached_background_color_ == color) |
| 791 return; | 791 return; |
| 792 | 792 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 943 delete this; | 943 delete this; |
| 944 } | 944 } |
| 945 | 945 |
| 946 void RenderWidgetHostViewAndroid::SetTooltipText( | 946 void RenderWidgetHostViewAndroid::SetTooltipText( |
| 947 const base::string16& tooltip_text) { | 947 const base::string16& tooltip_text) { |
| 948 // Tooltips don't makes sense on Android. | 948 // Tooltips don't makes sense on Android. |
| 949 } | 949 } |
| 950 | 950 |
| 951 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, | 951 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, |
| 952 size_t offset, | 952 size_t offset, |
| 953 const gfx::Range& range) { | 953 const gfx::Range& range) { |
|
EhsanK
2017/01/13 21:55:23
Similar to the OnUpdateTextInputStateCalled() abov
| |
| 954 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); | 954 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); |
| 955 | 955 |
| 956 if (!content_view_core_) | 956 if (!content_view_core_ || is_in_vr_) |
| 957 return; | 957 return; |
| 958 if (range.is_empty()) { | 958 if (range.is_empty()) { |
| 959 content_view_core_->OnSelectionChanged(""); | 959 content_view_core_->OnSelectionChanged(""); |
| 960 return; | 960 return; |
| 961 } | 961 } |
| 962 | 962 |
| 963 DCHECK(!text.empty()); | 963 DCHECK(!text.empty()); |
| 964 size_t pos = range.GetMin() - offset; | 964 size_t pos = range.GetMin() - offset; |
| 965 size_t n = range.length(); | 965 size_t n = range.length(); |
| 966 | 966 |
| 967 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; | 967 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; |
| 968 if (pos >= text.length()) { | 968 if (pos >= text.length()) { |
| 969 NOTREACHED() << "The text can not cover range."; | 969 NOTREACHED() << "The text can not cover range."; |
| 970 return; | 970 return; |
| 971 } | 971 } |
| 972 | 972 |
| 973 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n)); | 973 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n)); |
| 974 | 974 |
| 975 content_view_core_->OnSelectionChanged(utf8_selection); | 975 content_view_core_->OnSelectionChanged(utf8_selection); |
|
EhsanK
2017/01/13 21:55:23
I am not familiar with Java side, but, looking at
asimjour
2017/01/16 19:28:40
the CL description is updated.
EhsanK
2017/01/16 20:23:11
Acknowledged.
| |
| 976 } | 976 } |
| 977 | 977 |
| 978 void RenderWidgetHostViewAndroid::SetBackgroundColor(SkColor color) { | 978 void RenderWidgetHostViewAndroid::SetBackgroundColor(SkColor color) { |
| 979 RenderWidgetHostViewBase::SetBackgroundColor(color); | 979 RenderWidgetHostViewBase::SetBackgroundColor(color); |
| 980 host_->SetBackgroundOpaque(GetBackgroundOpaque()); | 980 host_->SetBackgroundOpaque(GetBackgroundOpaque()); |
| 981 UpdateBackgroundColor(color); | 981 UpdateBackgroundColor(color); |
| 982 } | 982 } |
| 983 | 983 |
| 984 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( | 984 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( |
| 985 const gfx::Rect& src_subrect, | 985 const gfx::Rect& src_subrect, |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1532 // switches to Surfaces and the Browser's commit isn't in the critical path. | 1532 // switches to Surfaces and the Browser's commit isn't in the critical path. |
| 1533 args.deadline = sync_compositor_ ? base::TimeTicks() | 1533 args.deadline = sync_compositor_ ? base::TimeTicks() |
| 1534 : args.frame_time + (args.interval * 0.6); | 1534 : args.frame_time + (args.interval * 0.6); |
| 1535 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); | 1535 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
| 1536 if (sync_compositor_) | 1536 if (sync_compositor_) |
| 1537 sync_compositor_->DidSendBeginFrame(view_.GetWindowAndroid()); | 1537 sync_compositor_->DidSendBeginFrame(view_.GetWindowAndroid()); |
| 1538 } | 1538 } |
| 1539 | 1539 |
| 1540 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { | 1540 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { |
| 1541 bool needs_animate = false; | 1541 bool needs_animate = false; |
| 1542 if (overscroll_controller_ && is_showing_overscroll_glow_) { | 1542 if (overscroll_controller_ && !is_in_vr_) { |
| 1543 needs_animate |= overscroll_controller_->Animate( | 1543 needs_animate |= overscroll_controller_->Animate( |
| 1544 frame_time, content_view_core_->GetViewAndroid()->GetLayer()); | 1544 frame_time, content_view_core_->GetViewAndroid()->GetLayer()); |
| 1545 } | 1545 } |
| 1546 if (selection_controller_) | 1546 if (selection_controller_) |
| 1547 needs_animate |= selection_controller_->Animate(frame_time); | 1547 needs_animate |= selection_controller_->Animate(frame_time); |
| 1548 return needs_animate; | 1548 return needs_animate; |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() { | 1551 void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() { |
| 1552 if (content_view_core_) | 1552 if (content_view_core_) |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1747 | 1747 |
| 1748 void RenderWidgetHostViewAndroid::SetTextHandlesTemporarilyHidden(bool hidden) { | 1748 void RenderWidgetHostViewAndroid::SetTextHandlesTemporarilyHidden(bool hidden) { |
| 1749 if (selection_controller_) | 1749 if (selection_controller_) |
| 1750 selection_controller_->SetTemporarilyHidden(hidden); | 1750 selection_controller_->SetTemporarilyHidden(hidden); |
| 1751 } | 1751 } |
| 1752 | 1752 |
| 1753 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 1753 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
| 1754 return cached_background_color_; | 1754 return cached_background_color_; |
| 1755 } | 1755 } |
| 1756 | 1756 |
| 1757 void RenderWidgetHostViewAndroid::SetShowingOverscrollGlow(bool showing_glow) { | 1757 void RenderWidgetHostViewAndroid::SetIsInVR(bool is_in_vr) { |
| 1758 is_showing_overscroll_glow_ = showing_glow; | 1758 is_in_vr_ = is_in_vr; |
| 1759 } | 1759 } |
| 1760 | 1760 |
| 1761 void RenderWidgetHostViewAndroid::DidOverscroll( | 1761 void RenderWidgetHostViewAndroid::DidOverscroll( |
| 1762 const ui::DidOverscrollParams& params) { | 1762 const ui::DidOverscrollParams& params) { |
| 1763 if (sync_compositor_) | 1763 if (sync_compositor_) |
| 1764 sync_compositor_->DidOverscroll(params); | 1764 sync_compositor_->DidOverscroll(params); |
| 1765 | 1765 |
| 1766 if (!content_view_core_ || !is_showing_) | 1766 if (!content_view_core_ || !is_showing_) |
| 1767 return; | 1767 return; |
| 1768 | 1768 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2072 if (!window_android) | 2072 if (!window_android) |
| 2073 return; | 2073 return; |
| 2074 | 2074 |
| 2075 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2075 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2076 if (!compositor) | 2076 if (!compositor) |
| 2077 return; | 2077 return; |
| 2078 | 2078 |
| 2079 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2079 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2080 overscroll_refresh_handler, compositor, | 2080 overscroll_refresh_handler, compositor, |
| 2081 ui::GetScaleFactorForNativeView(GetNativeView())); | 2081 ui::GetScaleFactorForNativeView(GetNativeView())); |
| 2082 is_showing_overscroll_glow_ = true; | |
| 2083 } | 2082 } |
| 2084 | 2083 |
| 2085 } // namespace content | 2084 } // namespace content |
| OLD | NEW |