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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 } | 626 } |
627 | 627 |
628 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { | 628 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { |
629 if (!content_view_core_) | 629 if (!content_view_core_) |
630 return 0.f; | 630 return 0.f; |
631 | 631 |
632 // The height of the top controls. | 632 // The height of the top controls. |
633 return content_view_core_->GetTopControlsHeightDip(); | 633 return content_view_core_->GetTopControlsHeightDip(); |
634 } | 634 } |
635 | 635 |
| 636 float RenderWidgetHostViewAndroid::GetBottomControlsHeight() const { |
| 637 if (!content_view_core_) |
| 638 return 0.f; |
| 639 |
| 640 // The height of the top controls. |
| 641 return content_view_core_->GetBottomControlsHeightDip(); |
| 642 } |
| 643 |
636 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { | 644 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { |
637 // There are no cursors on Android. | 645 // There are no cursors on Android. |
638 } | 646 } |
639 | 647 |
640 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { | 648 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { |
641 // Do nothing. The UI notification is handled through ContentViewClient which | 649 // Do nothing. The UI notification is handled through ContentViewClient which |
642 // is TabContentsDelegate. | 650 // is TabContentsDelegate. |
643 } | 651 } |
644 | 652 |
645 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { | 653 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 } | 1001 } |
994 | 1002 |
995 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( | 1003 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( |
996 cc::CompositorFrame frame) { | 1004 cc::CompositorFrame frame) { |
997 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); | 1005 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); |
998 if (!surface_factory_) { | 1006 if (!surface_factory_) { |
999 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); | 1007 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); |
1000 } | 1008 } |
1001 if (surface_id_.is_null() || | 1009 if (surface_id_.is_null() || |
1002 texture_size_in_layer_ != current_surface_size_ || | 1010 texture_size_in_layer_ != current_surface_size_ || |
1003 location_bar_content_translation_ != | 1011 top_bar_shown_ratio_ != frame.metadata.top_controls_shown_ratio || |
1004 frame.metadata.location_bar_content_translation || | 1012 bottom_bar_shown_ratio_ != frame.metadata.bottom_controls_shown_ratio || |
1005 current_viewport_selection_ != frame.metadata.selection) { | 1013 current_viewport_selection_ != frame.metadata.selection) { |
1006 RemoveLayers(); | 1014 RemoveLayers(); |
1007 if (!surface_id_.is_null()) | 1015 if (!surface_id_.is_null()) |
1008 surface_factory_->Destroy(surface_id_); | 1016 surface_factory_->Destroy(surface_id_); |
1009 surface_id_ = id_allocator_->GenerateId(); | 1017 surface_id_ = id_allocator_->GenerateId(); |
1010 surface_factory_->Create(surface_id_); | 1018 surface_factory_->Create(surface_id_); |
1011 layer_ = CreateSurfaceLayer(surface_id_, texture_size_in_layer_); | 1019 layer_ = CreateSurfaceLayer(surface_id_, texture_size_in_layer_); |
1012 | 1020 |
1013 DCHECK(layer_); | 1021 DCHECK(layer_); |
1014 | 1022 |
1015 current_surface_size_ = texture_size_in_layer_; | 1023 current_surface_size_ = texture_size_in_layer_; |
1016 location_bar_content_translation_ = | 1024 top_bar_shown_ratio_ = frame.metadata.top_controls_shown_ratio; |
1017 frame.metadata.location_bar_content_translation; | 1025 bottom_bar_shown_ratio_ = frame.metadata.bottom_controls_shown_ratio; |
1018 current_viewport_selection_ = frame.metadata.selection; | 1026 current_viewport_selection_ = frame.metadata.selection; |
1019 AttachLayers(); | 1027 AttachLayers(); |
1020 } | 1028 } |
1021 | 1029 |
1022 cc::SurfaceFactory::DrawCallback ack_callback = | 1030 cc::SurfaceFactory::DrawCallback ack_callback = |
1023 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, | 1031 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, |
1024 weak_ptr_factory_.GetWeakPtr()); | 1032 weak_ptr_factory_.GetWeakPtr()); |
1025 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), | 1033 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame), |
1026 ack_callback); | 1034 ack_callback); |
1027 } | 1035 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 selection_controller_->OnSelectionEditable( | 1254 selection_controller_->OnSelectionEditable( |
1247 frame_metadata.selection.is_editable); | 1255 frame_metadata.selection.is_editable); |
1248 selection_controller_->OnSelectionEmpty( | 1256 selection_controller_->OnSelectionEmpty( |
1249 frame_metadata.selection.is_empty_text_form_control); | 1257 frame_metadata.selection.is_empty_text_form_control); |
1250 selection_controller_->OnSelectionBoundsChanged( | 1258 selection_controller_->OnSelectionBoundsChanged( |
1251 frame_metadata.selection.start, frame_metadata.selection.end); | 1259 frame_metadata.selection.start, frame_metadata.selection.end); |
1252 | 1260 |
1253 // Set parameters for adaptive handle orientation. | 1261 // Set parameters for adaptive handle orientation. |
1254 gfx::SizeF viewport_size(frame_metadata.scrollable_viewport_size); | 1262 gfx::SizeF viewport_size(frame_metadata.scrollable_viewport_size); |
1255 viewport_size.Scale(frame_metadata.page_scale_factor); | 1263 viewport_size.Scale(frame_metadata.page_scale_factor); |
1256 gfx::RectF viewport_rect( | 1264 gfx::RectF viewport_rect(0.0f, frame_metadata.top_controls_height.y() * |
1257 frame_metadata.location_bar_content_translation.x(), | 1265 frame_metadata.top_controls_shown_ratio, |
1258 frame_metadata.location_bar_content_translation.y(), | 1266 viewport_size.width(), viewport_size.height()); |
1259 viewport_size.width(), viewport_size.height()); | |
1260 selection_controller_->OnViewportChanged(viewport_rect); | 1267 selection_controller_->OnViewportChanged(viewport_rect); |
1261 } | 1268 } |
1262 | 1269 |
1263 UpdateBackgroundColor(frame_metadata.root_background_color); | 1270 UpdateBackgroundColor(frame_metadata.root_background_color); |
1264 | 1271 |
1265 // All offsets and sizes are in CSS pixels. | 1272 // All offsets and sizes are in CSS pixels. |
1266 content_view_core_->UpdateFrameInfo( | 1273 content_view_core_->UpdateFrameInfo( |
1267 frame_metadata.root_scroll_offset, | 1274 frame_metadata.root_scroll_offset, |
1268 frame_metadata.page_scale_factor, | 1275 frame_metadata.page_scale_factor, |
1269 gfx::Vector2dF(frame_metadata.min_page_scale_factor, | 1276 gfx::Vector2dF(frame_metadata.min_page_scale_factor, |
1270 frame_metadata.max_page_scale_factor), | 1277 frame_metadata.max_page_scale_factor), |
1271 frame_metadata.root_layer_size, | 1278 frame_metadata.root_layer_size, |
1272 frame_metadata.scrollable_viewport_size, | 1279 frame_metadata.scrollable_viewport_size, |
1273 frame_metadata.location_bar_offset, | 1280 frame_metadata.top_controls_height, |
1274 frame_metadata.location_bar_content_translation, | 1281 frame_metadata.top_controls_shown_ratio, |
| 1282 frame_metadata.bottom_controls_height, |
| 1283 frame_metadata.bottom_controls_shown_ratio, |
1275 is_mobile_optimized, | 1284 is_mobile_optimized, |
1276 frame_metadata.selection.start); | 1285 frame_metadata.selection.start); |
1277 #if defined(VIDEO_HOLE) | 1286 #if defined(VIDEO_HOLE) |
1278 if (host_) { | 1287 if (host_) { |
1279 WebContents* web_contents = | 1288 WebContents* web_contents = |
1280 WebContents::FromRenderViewHost(RenderViewHostImpl::From(host_)); | 1289 WebContents::FromRenderViewHost(RenderViewHostImpl::From(host_)); |
1281 if (web_contents) { | 1290 if (web_contents) { |
1282 MediaWebContentsObserverAndroid::FromWebContents(web_contents) | 1291 MediaWebContentsObserverAndroid::FromWebContents(web_contents) |
1283 ->OnFrameInfoUpdated(); | 1292 ->OnFrameInfoUpdated(); |
1284 } | 1293 } |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 case ui::MotionEvent::ACTION_UP: | 1999 case ui::MotionEvent::ACTION_UP: |
1991 case ui::MotionEvent::ACTION_POINTER_UP: | 2000 case ui::MotionEvent::ACTION_POINTER_UP: |
1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 2001 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
1993 delta.InMicroseconds(), 1, 1000000, 50); | 2002 delta.InMicroseconds(), 1, 1000000, 50); |
1994 default: | 2003 default: |
1995 return; | 2004 return; |
1996 } | 2005 } |
1997 } | 2006 } |
1998 | 2007 |
1999 } // namespace content | 2008 } // namespace content |
OLD | NEW |