| 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 628 } |
| 629 | 629 |
| 630 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { | 630 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { |
| 631 if (!content_view_core_) | 631 if (!content_view_core_) |
| 632 return 0.f; | 632 return 0.f; |
| 633 | 633 |
| 634 // The height of the top controls. | 634 // The height of the top controls. |
| 635 return content_view_core_->GetTopControlsHeightDip(); | 635 return content_view_core_->GetTopControlsHeightDip(); |
| 636 } | 636 } |
| 637 | 637 |
| 638 float RenderWidgetHostViewAndroid::GetBottomControlsHeight() const { |
| 639 if (!content_view_core_) |
| 640 return 0.f; |
| 641 |
| 642 // The height of the top controls. |
| 643 return content_view_core_->GetBottomControlsHeightDip(); |
| 644 } |
| 645 |
| 638 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { | 646 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { |
| 639 // There are no cursors on Android. | 647 // There are no cursors on Android. |
| 640 } | 648 } |
| 641 | 649 |
| 642 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { | 650 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { |
| 643 // Do nothing. The UI notification is handled through ContentViewClient which | 651 // Do nothing. The UI notification is handled through ContentViewClient which |
| 644 // is TabContentsDelegate. | 652 // is TabContentsDelegate. |
| 645 } | 653 } |
| 646 | 654 |
| 647 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { | 655 long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 } | 1003 } |
| 996 | 1004 |
| 997 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( | 1005 void RenderWidgetHostViewAndroid::SubmitCompositorFrame( |
| 998 cc::CompositorFrame frame) { | 1006 cc::CompositorFrame frame) { |
| 999 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); | 1007 cc::SurfaceManager* manager = CompositorImpl::GetSurfaceManager(); |
| 1000 if (!surface_factory_) { | 1008 if (!surface_factory_) { |
| 1001 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); | 1009 surface_factory_ = base::WrapUnique(new cc::SurfaceFactory(manager, this)); |
| 1002 } | 1010 } |
| 1003 if (surface_id_.is_null() || | 1011 if (surface_id_.is_null() || |
| 1004 texture_size_in_layer_ != current_surface_size_ || | 1012 texture_size_in_layer_ != current_surface_size_ || |
| 1005 location_bar_content_translation_ != | 1013 top_bar_shown_ != frame.metadata.top_bar_shown || |
| 1006 frame.metadata.location_bar_content_translation || | |
| 1007 current_viewport_selection_ != frame.metadata.selection) { | 1014 current_viewport_selection_ != frame.metadata.selection) { |
| 1008 RemoveLayers(); | 1015 RemoveLayers(); |
| 1009 if (!surface_id_.is_null()) | 1016 if (!surface_id_.is_null()) |
| 1010 surface_factory_->Destroy(surface_id_); | 1017 surface_factory_->Destroy(surface_id_); |
| 1011 surface_id_ = id_allocator_->GenerateId(); | 1018 surface_id_ = id_allocator_->GenerateId(); |
| 1012 surface_factory_->Create(surface_id_); | 1019 surface_factory_->Create(surface_id_); |
| 1013 layer_ = CreateDelegatedLayer(); | 1020 layer_ = CreateDelegatedLayer(); |
| 1014 | 1021 |
| 1015 DCHECK(layer_); | 1022 DCHECK(layer_); |
| 1016 | 1023 |
| 1017 current_surface_size_ = texture_size_in_layer_; | 1024 current_surface_size_ = texture_size_in_layer_; |
| 1018 location_bar_content_translation_ = | 1025 top_bar_shown_ = frame.metadata.top_bar_shown; |
| 1019 frame.metadata.location_bar_content_translation; | |
| 1020 current_viewport_selection_ = frame.metadata.selection; | 1026 current_viewport_selection_ = frame.metadata.selection; |
| 1021 AttachLayers(); | 1027 AttachLayers(); |
| 1022 } | 1028 } |
| 1023 | 1029 |
| 1024 cc::SurfaceFactory::DrawCallback ack_callback = | 1030 cc::SurfaceFactory::DrawCallback ack_callback = |
| 1025 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, | 1031 base::Bind(&RenderWidgetHostViewAndroid::RunAckCallbacks, |
| 1026 weak_ptr_factory_.GetWeakPtr()); | 1032 weak_ptr_factory_.GetWeakPtr()); |
| 1027 std::unique_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame); | 1033 std::unique_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame); |
| 1028 *frame_copy = std::move(frame); | 1034 *frame_copy = std::move(frame); |
| 1029 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame_copy), | 1035 surface_factory_->SubmitCompositorFrame(surface_id_, std::move(frame_copy), |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 selection_controller_->OnSelectionEditable( | 1284 selection_controller_->OnSelectionEditable( |
| 1279 frame_metadata.selection.is_editable); | 1285 frame_metadata.selection.is_editable); |
| 1280 selection_controller_->OnSelectionEmpty( | 1286 selection_controller_->OnSelectionEmpty( |
| 1281 frame_metadata.selection.is_empty_text_form_control); | 1287 frame_metadata.selection.is_empty_text_form_control); |
| 1282 selection_controller_->OnSelectionBoundsChanged( | 1288 selection_controller_->OnSelectionBoundsChanged( |
| 1283 frame_metadata.selection.start, frame_metadata.selection.end); | 1289 frame_metadata.selection.start, frame_metadata.selection.end); |
| 1284 | 1290 |
| 1285 // Set parameters for adaptive handle orientation. | 1291 // Set parameters for adaptive handle orientation. |
| 1286 gfx::SizeF viewport_size(frame_metadata.scrollable_viewport_size); | 1292 gfx::SizeF viewport_size(frame_metadata.scrollable_viewport_size); |
| 1287 viewport_size.Scale(frame_metadata.page_scale_factor); | 1293 viewport_size.Scale(frame_metadata.page_scale_factor); |
| 1288 gfx::RectF viewport_rect( | 1294 gfx::RectF viewport_rect(frame_metadata.top_bar_shown.x(), |
| 1289 frame_metadata.location_bar_content_translation.x(), | 1295 frame_metadata.top_bar_shown.y(), |
| 1290 frame_metadata.location_bar_content_translation.y(), | 1296 viewport_size.width(), viewport_size.height()); |
| 1291 viewport_size.width(), viewport_size.height()); | |
| 1292 selection_controller_->OnViewportChanged(viewport_rect); | 1297 selection_controller_->OnViewportChanged(viewport_rect); |
| 1293 } | 1298 } |
| 1294 | 1299 |
| 1295 UpdateBackgroundColor(frame_metadata.root_background_color); | 1300 UpdateBackgroundColor(frame_metadata.root_background_color); |
| 1296 | 1301 |
| 1297 // All offsets and sizes are in CSS pixels. | 1302 // All offsets and sizes are in CSS pixels. |
| 1298 content_view_core_->UpdateFrameInfo( | 1303 content_view_core_->UpdateFrameInfo( |
| 1299 frame_metadata.root_scroll_offset, | 1304 frame_metadata.root_scroll_offset, |
| 1300 frame_metadata.page_scale_factor, | 1305 frame_metadata.page_scale_factor, |
| 1301 gfx::Vector2dF(frame_metadata.min_page_scale_factor, | 1306 gfx::Vector2dF(frame_metadata.min_page_scale_factor, |
| 1302 frame_metadata.max_page_scale_factor), | 1307 frame_metadata.max_page_scale_factor), |
| 1303 frame_metadata.root_layer_size, | 1308 frame_metadata.root_layer_size, |
| 1304 frame_metadata.scrollable_viewport_size, | 1309 frame_metadata.scrollable_viewport_size, |
| 1305 frame_metadata.location_bar_offset, | 1310 frame_metadata.top_bar_translate, |
| 1306 frame_metadata.location_bar_content_translation, | 1311 frame_metadata.top_bar_shown, |
| 1312 frame_metadata.bottom_bar_translate, |
| 1313 frame_metadata.bottom_bar_shown, |
| 1307 is_mobile_optimized, | 1314 is_mobile_optimized, |
| 1308 frame_metadata.selection.start); | 1315 frame_metadata.selection.start); |
| 1309 #if defined(VIDEO_HOLE) | 1316 #if defined(VIDEO_HOLE) |
| 1310 if (host_) { | 1317 if (host_) { |
| 1311 WebContents* web_contents = | 1318 WebContents* web_contents = |
| 1312 WebContents::FromRenderViewHost(RenderViewHostImpl::From(host_)); | 1319 WebContents::FromRenderViewHost(RenderViewHostImpl::From(host_)); |
| 1313 if (web_contents) { | 1320 if (web_contents) { |
| 1314 MediaWebContentsObserverAndroid::FromWebContents(web_contents) | 1321 MediaWebContentsObserverAndroid::FromWebContents(web_contents) |
| 1315 ->OnFrameInfoUpdated(); | 1322 ->OnFrameInfoUpdated(); |
| 1316 } | 1323 } |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 case ui::MotionEvent::ACTION_UP: | 2029 case ui::MotionEvent::ACTION_UP: |
| 2023 case ui::MotionEvent::ACTION_POINTER_UP: | 2030 case ui::MotionEvent::ACTION_POINTER_UP: |
| 2024 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 2031 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 2025 delta.InMicroseconds(), 1, 1000000, 50); | 2032 delta.InMicroseconds(), 1, 1000000, 50); |
| 2026 default: | 2033 default: |
| 2027 return; | 2034 return; |
| 2028 } | 2035 } |
| 2029 } | 2036 } |
| 2030 | 2037 |
| 2031 } // namespace content | 2038 } // namespace content |
| OLD | NEW |