| 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_) |
| 780 return; | 780 return; |
| 781 | 781 |
| 782 content_view_core_->UpdateImeAdapter( | 782 content_view_core_->UpdateImeAdapter( |
| 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.reply_to_request); | 786 state.reply_to_request); |
| 787 } | 787 } |
| 788 | 788 |
| 789 void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged( | 789 void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged( |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 } | 951 } |
| 952 | 952 |
| 953 void RenderWidgetHostViewAndroid::SetTooltipText( | 953 void RenderWidgetHostViewAndroid::SetTooltipText( |
| 954 const base::string16& tooltip_text) { | 954 const base::string16& tooltip_text) { |
| 955 // Tooltips don't makes sense on Android. | 955 // Tooltips don't makes sense on Android. |
| 956 } | 956 } |
| 957 | 957 |
| 958 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, | 958 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, |
| 959 size_t offset, | 959 size_t offset, |
| 960 const gfx::Range& range) { | 960 const gfx::Range& range) { |
| 961 // TODO(asimjour): remove the flag and fix text selection popup for |
| 962 // virtual reality mode. |
| 963 if (is_in_vr_) |
| 964 return; |
| 965 |
| 961 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); | 966 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); |
| 962 | 967 |
| 963 if (!content_view_core_) | 968 if (!content_view_core_) |
| 964 return; | 969 return; |
| 965 if (range.is_empty()) { | 970 if (range.is_empty()) { |
| 966 content_view_core_->OnSelectionChanged(""); | 971 content_view_core_->OnSelectionChanged(""); |
| 967 return; | 972 return; |
| 968 } | 973 } |
| 969 | 974 |
| 970 DCHECK(!text.empty()); | 975 DCHECK(!text.empty()); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 // switches to Surfaces and the Browser's commit isn't in the critical path. | 1544 // switches to Surfaces and the Browser's commit isn't in the critical path. |
| 1540 args.deadline = sync_compositor_ ? base::TimeTicks() | 1545 args.deadline = sync_compositor_ ? base::TimeTicks() |
| 1541 : args.frame_time + (args.interval * 0.6); | 1546 : args.frame_time + (args.interval * 0.6); |
| 1542 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); | 1547 host_->Send(new ViewMsg_BeginFrame(host_->GetRoutingID(), args)); |
| 1543 if (sync_compositor_) | 1548 if (sync_compositor_) |
| 1544 sync_compositor_->DidSendBeginFrame(view_.GetWindowAndroid()); | 1549 sync_compositor_->DidSendBeginFrame(view_.GetWindowAndroid()); |
| 1545 } | 1550 } |
| 1546 | 1551 |
| 1547 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { | 1552 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { |
| 1548 bool needs_animate = false; | 1553 bool needs_animate = false; |
| 1549 if (overscroll_controller_ && is_showing_overscroll_glow_) { | 1554 if (overscroll_controller_ && !is_in_vr_) { |
| 1550 needs_animate |= overscroll_controller_->Animate( | 1555 needs_animate |= overscroll_controller_->Animate( |
| 1551 frame_time, content_view_core_->GetViewAndroid()->GetLayer()); | 1556 frame_time, content_view_core_->GetViewAndroid()->GetLayer()); |
| 1552 } | 1557 } |
| 1553 if (selection_controller_) | 1558 if (selection_controller_) |
| 1554 needs_animate |= selection_controller_->Animate(frame_time); | 1559 needs_animate |= selection_controller_->Animate(frame_time); |
| 1555 return needs_animate; | 1560 return needs_animate; |
| 1556 } | 1561 } |
| 1557 | 1562 |
| 1558 void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() { | 1563 void RenderWidgetHostViewAndroid::RequestDisallowInterceptTouchEvent() { |
| 1559 if (content_view_core_) | 1564 if (content_view_core_) |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 | 1759 |
| 1755 void RenderWidgetHostViewAndroid::SetTextHandlesTemporarilyHidden(bool hidden) { | 1760 void RenderWidgetHostViewAndroid::SetTextHandlesTemporarilyHidden(bool hidden) { |
| 1756 if (selection_controller_) | 1761 if (selection_controller_) |
| 1757 selection_controller_->SetTemporarilyHidden(hidden); | 1762 selection_controller_->SetTemporarilyHidden(hidden); |
| 1758 } | 1763 } |
| 1759 | 1764 |
| 1760 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 1765 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
| 1761 return cached_background_color_; | 1766 return cached_background_color_; |
| 1762 } | 1767 } |
| 1763 | 1768 |
| 1764 void RenderWidgetHostViewAndroid::SetShowingOverscrollGlow(bool showing_glow) { | 1769 void RenderWidgetHostViewAndroid::SetIsInVR(bool is_in_vr) { |
| 1765 is_showing_overscroll_glow_ = showing_glow; | 1770 is_in_vr_ = is_in_vr; |
| 1766 } | 1771 } |
| 1767 | 1772 |
| 1768 void RenderWidgetHostViewAndroid::DidOverscroll( | 1773 void RenderWidgetHostViewAndroid::DidOverscroll( |
| 1769 const ui::DidOverscrollParams& params) { | 1774 const ui::DidOverscrollParams& params) { |
| 1770 if (sync_compositor_) | 1775 if (sync_compositor_) |
| 1771 sync_compositor_->DidOverscroll(params); | 1776 sync_compositor_->DidOverscroll(params); |
| 1772 | 1777 |
| 1773 if (!content_view_core_ || !is_showing_) | 1778 if (!content_view_core_ || !is_showing_) |
| 1774 return; | 1779 return; |
| 1775 | 1780 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 if (!window_android) | 2084 if (!window_android) |
| 2080 return; | 2085 return; |
| 2081 | 2086 |
| 2082 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2087 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2083 if (!compositor) | 2088 if (!compositor) |
| 2084 return; | 2089 return; |
| 2085 | 2090 |
| 2086 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2091 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2087 overscroll_refresh_handler, compositor, | 2092 overscroll_refresh_handler, compositor, |
| 2088 ui::GetScaleFactorForNativeView(GetNativeView())); | 2093 ui::GetScaleFactorForNativeView(GetNativeView())); |
| 2089 is_showing_overscroll_glow_ = true; | |
| 2090 } | 2094 } |
| 2091 | 2095 |
| 2092 } // namespace content | 2096 } // namespace content |
| OLD | NEW |