Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2106753004: Introduce bottom controls to CC and let it respond to scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: vector->float in IPC Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 413
414 // All positions and sizes are in CSS pixels. 414 // All positions and sizes are in CSS pixels.
415 // Note that viewport_width/height is a best effort based. 415 // Note that viewport_width/height is a best effort based.
416 // ContentViewCore has the actual information about the physical viewport size. 416 // ContentViewCore has the actual information about the physical viewport size.
417 void ContentViewCoreImpl::UpdateFrameInfo( 417 void ContentViewCoreImpl::UpdateFrameInfo(
418 const gfx::Vector2dF& scroll_offset, 418 const gfx::Vector2dF& scroll_offset,
419 float page_scale_factor, 419 float page_scale_factor,
420 const gfx::Vector2dF& page_scale_factor_limits, 420 const gfx::Vector2dF& page_scale_factor_limits,
421 const gfx::SizeF& content_size, 421 const gfx::SizeF& content_size,
422 const gfx::SizeF& viewport_size, 422 const gfx::SizeF& viewport_size,
423 const gfx::Vector2dF& controls_offset, 423 const float top_controls_height,
424 const gfx::Vector2dF& content_offset, 424 const float top_controls_shown_ratio,
425 const float bottom_controls_height,
426 const float bottom_controls_shown_ratio,
425 bool is_mobile_optimized_hint, 427 bool is_mobile_optimized_hint,
426 const gfx::SelectionBound& selection_start) { 428 const gfx::SelectionBound& selection_start) {
427 JNIEnv* env = AttachCurrentThread(); 429 JNIEnv* env = AttachCurrentThread();
428 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 430 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
429 if (obj.is_null() || !view_.GetWindowAndroid()) 431 if (obj.is_null() || !view_.GetWindowAndroid())
430 return; 432 return;
431 433
432 view_.GetWindowAndroid()->set_content_offset( 434 view_.GetWindowAndroid()->set_content_offset(gfx::ScaleVector2d(
433 gfx::ScaleVector2d(content_offset, dpi_scale_)); 435 gfx::Vector2dF(0.0f, top_controls_height * top_controls_shown_ratio),
436 dpi_scale_));
434 437
435 page_scale_ = page_scale_factor; 438 page_scale_ = page_scale_factor;
436 439
437 // The CursorAnchorInfo API in Android only supports zero width selection 440 // The CursorAnchorInfo API in Android only supports zero width selection
438 // bounds. 441 // bounds.
439 const jboolean has_insertion_marker = 442 const jboolean has_insertion_marker =
440 selection_start.type() == gfx::SelectionBound::CENTER; 443 selection_start.type() == gfx::SelectionBound::CENTER;
441 const jboolean is_insertion_marker_visible = selection_start.visible(); 444 const jboolean is_insertion_marker_visible = selection_start.visible();
442 const jfloat insertion_marker_horizontal = 445 const jfloat insertion_marker_horizontal =
443 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; 446 has_insertion_marker ? selection_start.edge_top().x() : 0.0f;
444 const jfloat insertion_marker_top = 447 const jfloat insertion_marker_top =
445 has_insertion_marker ? selection_start.edge_top().y() : 0.0f; 448 has_insertion_marker ? selection_start.edge_top().y() : 0.0f;
446 const jfloat insertion_marker_bottom = 449 const jfloat insertion_marker_bottom =
447 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; 450 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f;
448 451
449 Java_ContentViewCore_updateFrameInfo( 452 Java_ContentViewCore_updateFrameInfo(
450 env, obj.obj(), 453 env, obj.obj(),
451 scroll_offset.x(), 454 scroll_offset.x(),
452 scroll_offset.y(), 455 scroll_offset.y(),
453 page_scale_factor, 456 page_scale_factor,
454 page_scale_factor_limits.x(), 457 page_scale_factor_limits.x(),
455 page_scale_factor_limits.y(), 458 page_scale_factor_limits.y(),
456 content_size.width(), 459 content_size.width(),
457 content_size.height(), 460 content_size.height(),
458 viewport_size.width(), 461 viewport_size.width(),
459 viewport_size.height(), 462 viewport_size.height(),
460 controls_offset.y(), 463 top_controls_height,
461 content_offset.y(), 464 top_controls_shown_ratio,
465 bottom_controls_height,
466 bottom_controls_shown_ratio,
462 is_mobile_optimized_hint, 467 is_mobile_optimized_hint,
463 has_insertion_marker, 468 has_insertion_marker,
464 is_insertion_marker_visible, 469 is_insertion_marker_visible,
465 insertion_marker_horizontal, 470 insertion_marker_horizontal,
466 insertion_marker_top, 471 insertion_marker_top,
467 insertion_marker_bottom); 472 insertion_marker_bottom);
468 } 473 }
469 474
470 void ContentViewCoreImpl::SetTitle(const base::string16& title) { 475 void ContentViewCoreImpl::SetTitle(const base::string16& title) {
471 JNIEnv* env = AttachCurrentThread(); 476 JNIEnv* env = AttachCurrentThread();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 782
778 gfx::Size size_dip = gfx::ScaleToCeiledSize(size_pix, 1.0f / dpi_scale()); 783 gfx::Size size_dip = gfx::ScaleToCeiledSize(size_pix, 1.0f / dpi_scale());
779 if (DoTopControlsShrinkBlinkSize()) 784 if (DoTopControlsShrinkBlinkSize())
780 size_dip.Enlarge(0, -GetTopControlsHeightDip()); 785 size_dip.Enlarge(0, -GetTopControlsHeightDip());
781 return size_dip; 786 return size_dip;
782 } 787 }
783 788
784 gfx::Size ContentViewCoreImpl::GetViewSize() const { 789 gfx::Size ContentViewCoreImpl::GetViewSize() const {
785 gfx::Size size = GetViewportSizeDip(); 790 gfx::Size size = GetViewportSizeDip();
786 if (DoTopControlsShrinkBlinkSize()) 791 if (DoTopControlsShrinkBlinkSize())
787 size.Enlarge(0, -GetTopControlsHeightDip()); 792 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip());
788 return size; 793 return size;
789 } 794 }
790 795
791 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { 796 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const {
792 JNIEnv* env = AttachCurrentThread(); 797 JNIEnv* env = AttachCurrentThread();
793 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 798 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
794 if (j_obj.is_null()) 799 if (j_obj.is_null())
795 return gfx::Size(); 800 return gfx::Size();
796 return gfx::Size( 801 return gfx::Size(
797 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()), 802 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()),
(...skipping 11 matching lines...) Expand all
809 } 814 }
810 815
811 int ContentViewCoreImpl::GetTopControlsHeightPix() const { 816 int ContentViewCoreImpl::GetTopControlsHeightPix() const {
812 JNIEnv* env = AttachCurrentThread(); 817 JNIEnv* env = AttachCurrentThread();
813 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 818 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
814 if (j_obj.is_null()) 819 if (j_obj.is_null())
815 return 0; 820 return 0;
816 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj.obj()); 821 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj.obj());
817 } 822 }
818 823
824 int ContentViewCoreImpl::GetBottomControlsHeightPix() const {
825 JNIEnv* env = AttachCurrentThread();
826 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
827 if (j_obj.is_null())
828 return 0;
829 return Java_ContentViewCore_getBottomControlsHeightPix(env, j_obj.obj());
830 }
831
819 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { 832 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const {
820 return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale()); 833 return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale());
821 } 834 }
822 835
823 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const { 836 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const {
824 JNIEnv* env = AttachCurrentThread(); 837 JNIEnv* env = AttachCurrentThread();
825 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 838 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
826 if (j_obj.is_null()) 839 if (j_obj.is_null())
827 return false; 840 return false;
828 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj()); 841 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj());
829 } 842 }
830 843
831 float ContentViewCoreImpl::GetTopControlsHeightDip() const { 844 float ContentViewCoreImpl::GetTopControlsHeightDip() const {
832 return GetTopControlsHeightPix() / dpi_scale(); 845 return GetTopControlsHeightPix() / dpi_scale();
833 } 846 }
834 847
848 float ContentViewCoreImpl::GetBottomControlsHeightDip() const {
849 return GetBottomControlsHeightPix() / dpi_scale();
850 }
851
835 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { 852 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) {
836 view_.GetLayer()->InsertChild(layer, 0); 853 view_.GetLayer()->InsertChild(layer, 0);
837 view_.GetLayer()->SetIsDrawable(false); 854 view_.GetLayer()->SetIsDrawable(false);
838 } 855 }
839 856
840 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { 857 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) {
841 layer->RemoveFromParent(); 858 layer->RemoveFromParent();
842 859
843 if (view_.GetLayer()->children().empty()) 860 if (view_.GetLayer()->children().empty())
844 view_.GetLayer()->SetIsDrawable(true); 861 view_.GetLayer()->SetIsDrawable(true);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 return ScopedJavaLocalRef<jobject>(); 1655 return ScopedJavaLocalRef<jobject>();
1639 1656
1640 return view->GetJavaObject(); 1657 return view->GetJavaObject();
1641 } 1658 }
1642 1659
1643 bool RegisterContentViewCore(JNIEnv* env) { 1660 bool RegisterContentViewCore(JNIEnv* env) {
1644 return RegisterNativesImpl(env); 1661 return RegisterNativesImpl(env);
1645 } 1662 }
1646 1663
1647 } // namespace content 1664 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698