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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
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_) { |
569 return gfx::Size(); | 569 if (default_bounds_.IsEmpty()) return gfx::Size(); |
| 570 |
| 571 return gfx::Size(default_bounds_.right() |
| 572 * ui::GetScaleFactorForNativeView(GetNativeView()), |
| 573 default_bounds_.bottom() |
| 574 * ui::GetScaleFactorForNativeView(GetNativeView())); |
| 575 } |
570 | 576 |
571 return content_view_core_->GetPhysicalBackingSize(); | 577 return content_view_core_->GetPhysicalBackingSize(); |
572 } | 578 } |
573 | 579 |
574 bool RenderWidgetHostViewAndroid::DoTopControlsShrinkBlinkSize() const { | 580 bool RenderWidgetHostViewAndroid::DoTopControlsShrinkBlinkSize() const { |
575 // Whether or not Blink's viewport size should be shrunk by the height of the | 581 // Whether or not Blink's viewport size should be shrunk by the height of the |
576 // URL-bar. | 582 // URL-bar. |
577 return content_view_core_ && | 583 return content_view_core_ && |
578 content_view_core_->DoTopControlsShrinkBlinkSize(); | 584 content_view_core_->DoTopControlsShrinkBlinkSize(); |
579 } | 585 } |
580 | 586 |
581 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { | 587 float RenderWidgetHostViewAndroid::GetTopControlsHeight() const { |
582 if (!content_view_core_) | 588 if (!content_view_core_) |
583 return 0.f; | 589 return default_bounds_.x(); |
584 | 590 |
585 // The height of the top controls. | 591 // The height of the top controls. |
586 return content_view_core_->GetTopControlsHeightDip(); | 592 return content_view_core_->GetTopControlsHeightDip(); |
587 } | 593 } |
588 | 594 |
589 float RenderWidgetHostViewAndroid::GetBottomControlsHeight() const { | 595 float RenderWidgetHostViewAndroid::GetBottomControlsHeight() const { |
590 if (!content_view_core_) | 596 if (!content_view_core_) |
591 return 0.f; | 597 return 0.f; |
592 | 598 |
593 // The height of the top controls. | 599 // The height of the top controls. |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 case ui::MotionEvent::ACTION_UP: | 1868 case ui::MotionEvent::ACTION_UP: |
1863 case ui::MotionEvent::ACTION_POINTER_UP: | 1869 case ui::MotionEvent::ACTION_POINTER_UP: |
1864 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1870 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
1865 delta.InMicroseconds(), 1, 1000000, 50); | 1871 delta.InMicroseconds(), 1, 1000000, 50); |
1866 default: | 1872 default: |
1867 return; | 1873 return; |
1868 } | 1874 } |
1869 } | 1875 } |
1870 | 1876 |
1871 } // namespace content | 1877 } // namespace content |
OLD | NEW |