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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 } | 377 } |
| 378 | 378 |
| 379 void RenderWidgetHostViewAndroid::WasResized() { | 379 void RenderWidgetHostViewAndroid::WasResized() { |
| 380 if (delegated_frame_host_ && content_view_core_) | 380 if (delegated_frame_host_ && content_view_core_) |
| 381 delegated_frame_host_->UpdateContainerSizeinDIP( | 381 delegated_frame_host_->UpdateContainerSizeinDIP( |
| 382 content_view_core_->GetViewportSizeDip()); | 382 content_view_core_->GetViewportSizeDip()); |
| 383 host_->WasResized(); | 383 host_->WasResized(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { | 386 void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) { |
| 387 // Ignore the given size as only the Java code has the power to | 387 // Ignore the given size as only the Java code has the power to |
|
no sievers
2016/08/23 21:24:39
Hmm looks like we don't implement this function co
Yusuf
2016/08/23 21:30:47
I think until now, we pretty much ignored any setS
| |
| 388 // resize the view on Android. | 388 // resize the view on Android. |
| 389 default_size_ = size; | 389 default_bounds_ = gfx::Rect(default_bounds_.origin(), size); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { | 392 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { |
| 393 SetSize(rect.size()); | 393 default_bounds_ = rect; |
| 394 } | 394 } |
| 395 | 395 |
| 396 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( | 396 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( |
| 397 float scale, | 397 float scale, |
| 398 SkColorType preferred_color_type, | 398 SkColorType preferred_color_type, |
| 399 gfx::Rect src_subrect, | 399 gfx::Rect src_subrect, |
| 400 const ReadbackRequestCallback& result_callback) { | 400 const ReadbackRequestCallback& result_callback) { |
| 401 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { | 401 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { |
| 402 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 402 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
| 403 return; | 403 return; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 return; | 541 return; |
| 542 } | 542 } |
| 543 while (locks_on_frame_count_ > 0) { | 543 while (locks_on_frame_count_ > 0) { |
| 544 UnlockCompositingSurface(); | 544 UnlockCompositingSurface(); |
| 545 } | 545 } |
| 546 RunAckCallbacks(); | 546 RunAckCallbacks(); |
| 547 } | 547 } |
| 548 | 548 |
| 549 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { | 549 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { |
| 550 if (!content_view_core_) | 550 if (!content_view_core_) |
| 551 return gfx::Rect(default_size_); | 551 return default_bounds_; |
| 552 | 552 |
| 553 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 553 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 554 switches::kEnableOSKOverscroll)) | 554 switches::kEnableOSKOverscroll)) |
| 555 return gfx::Rect(content_view_core_->GetViewSizeWithOSKHidden()); | 555 return gfx::Rect(content_view_core_->GetViewSizeWithOSKHidden()); |
| 556 | 556 |
| 557 return gfx::Rect(content_view_core_->GetViewSize()); | 557 return gfx::Rect(content_view_core_->GetViewSize()); |
| 558 } | 558 } |
| 559 | 559 |
| 560 gfx::Size RenderWidgetHostViewAndroid::GetVisibleViewportSize() const { | 560 gfx::Size RenderWidgetHostViewAndroid::GetVisibleViewportSize() const { |
| 561 if (!content_view_core_) | 561 if (!content_view_core_) |
| 562 return default_size_; | 562 return default_bounds_.size(); |
| 563 | 563 |
| 564 return content_view_core_->GetViewSize(); | 564 return content_view_core_->GetViewSize(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 gfx::Size RenderWidgetHostViewAndroid::GetPhysicalBackingSize() const { | 567 gfx::Size RenderWidgetHostViewAndroid::GetPhysicalBackingSize() const { |
| 568 if (!content_view_core_) | 568 if (!content_view_core_) |
|
no sievers
2016/08/23 21:24:39
missing braces
| |
| 569 return gfx::Size(); | 569 if (default_bounds_.IsEmpty()) return gfx::Size(); |
| 570 return gfx::Size(default_bounds_.right() | |
| 571 * ui::GetScaleFactorForNativeView(GetNativeView()), | |
| 572 default_bounds_.bottom() | |
| 573 * ui::GetScaleFactorForNativeView(GetNativeView())); | |
| 570 | 574 |
| 571 return content_view_core_->GetPhysicalBackingSize(); | 575 return content_view_core_->GetPhysicalBackingSize(); |
| 572 } | 576 } |
| 573 | 577 |
| 574 bool RenderWidgetHostViewAndroid::DoTopControlsShrinkBlinkSize() const { | 578 bool RenderWidgetHostViewAndroid::DoTopControlsShrinkBlinkSize() const { |
| 575 // Whether or not Blink's viewport size should be shrunk by the height of the | 579 // Whether or not Blink's viewport size should be shrunk by the height of the |
| 576 // URL-bar. | 580 // URL-bar. |
| 577 return content_view_core_ && | 581 return content_view_core_ && |
| 578 content_view_core_->DoTopControlsShrinkBlinkSize(); | 582 content_view_core_->DoTopControlsShrinkBlinkSize(); |
| 579 } | 583 } |
| 580 | 584 |
| 581 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { | 585 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { |
| 582 if (!content_view_core_) | 586 if (!content_view_core_) |
| 583 return 0.f; | 587 return default_bounds_.x(); |
| 584 | 588 |
| 585 // The height of the top controls. | 589 // The height of the top controls. |
| 586 return content_view_core_->GetTopControlsHeightDip(); | 590 return content_view_core_->GetTopControlsHeightDip(); |
| 587 } | 591 } |
| 588 | 592 |
| 589 float RenderWidgetHostViewAndroid::GetBottomControlsHeight() const { | 593 float RenderWidgetHostViewAndroid::GetBottomControlsHeight() const { |
| 590 if (!content_view_core_) | 594 if (!content_view_core_) |
| 591 return 0.f; | 595 return 0.f; |
| 592 | 596 |
| 593 // The height of the top controls. | 597 // The height of the top controls. |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1851 case ui::MotionEvent::ACTION_UP: | 1855 case ui::MotionEvent::ACTION_UP: |
| 1852 case ui::MotionEvent::ACTION_POINTER_UP: | 1856 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1853 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1857 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1854 delta.InMicroseconds(), 1, 1000000, 50); | 1858 delta.InMicroseconds(), 1, 1000000, 50); |
| 1855 default: | 1859 default: |
| 1856 return; | 1860 return; |
| 1857 } | 1861 } |
| 1858 } | 1862 } |
| 1859 | 1863 |
| 1860 } // namespace content | 1864 } // namespace content |
| OLD | NEW |